Beispiel #1
0
def heads(directory=None, verbose=False, resolve_dependencies=False):
    """Show current available heads in the script directory"""
    if alembic_version >= (0, 7, 0):
        config = _get_config(directory)
        command.heads(config, verbose=verbose, resolve_dependencies=resolve_dependencies)
    else:
        raise RuntimeError("Alembic 0.7.0 or greater is required")
Beispiel #2
0
def heads(directory=None, verbose=False, resolve_dependencies=False):
    """Show current available heads in the script directory"""
    if alembic_version >= (0, 7, 0):
        config = _get_config(directory)
        command.heads(config, verbose=verbose,
                      resolve_dependencies=resolve_dependencies)
    else:
        raise RuntimeError('Alembic 0.7.0 or greater is required')
Beispiel #3
0
 def heads(self,
           directory=None,
           verbose=False,
           resolve_dependencies=False,
           **kwargs):  # pragma: no cover
     """Show current available heads in the script directory"""
     config = _get_config(directory)
     command.heads(config,
                   verbose=verbose,
                   resolve_dependencies=resolve_dependencies)
 def heads(context, directory='migrations', verbose=False, resolve_dependencies=False):
     """Show current available heads in the script directory"""
     from app import create_app
     with create_app().app_context():
         if alembic_version >= (0, 7, 0):
             config = _get_config(directory)
             command.heads(config, verbose=verbose,
                           resolve_dependencies=resolve_dependencies)
         else:
             raise RuntimeError('Alembic 0.7.0 or greater is required')
Beispiel #5
0
def get_heads_version(alembic_cfg):
    captured_text = []

    def print_stdout(text, *arg):
        nonlocal captured_text
        captured_text.append(text)

    alembic_cfg.print_stdout = print_stdout
    command.heads(alembic_cfg)
    return captured_text
Beispiel #6
0
    def test_alembic_head(self):
        heads_ = StringIO()
        alembic_cfg = Config(stdout=heads_)
        alembic_cfg.set_main_option("script_location",
                                    os.path.dirname(inspect.getfile(migrations)))
        command.heads(alembic_cfg)
        heads = heads_.getvalue()
        heads = heads[:-1]

        self.assertNotIn('\n', heads)
Beispiel #7
0
def cli_db_heads(verbose, resolve_dependencies):
    """
    Revert to a previous version.
    """
    alembic_cfg = AlembicConfig("alembic.ini")
    alembic_cfg.set_main_option("script_location",
                                str(Path() / "db_migrations"))
    command.heads(config=alembic_cfg,
                  verbose=verbose,
                  resolve_dependencies=resolve_dependencies)
Beispiel #8
0
def heads(app,
          *,
          verbose: 'use more verbose output' = False,
          resolve_dependencies: (
              'treat dependency versions as down revisions') = False):
    """Show current available heads in the script directory."""
    alembic.heads(
        _get_config(app),
        verbose=verbose,
        resolve_dependencies=resolve_dependencies,
    )
def heads(app,
          *,
          verbose: 'use more verbose output' = False,
          resolve_dependencies: (
              'treat dependency versions as down revisions') = False):
    """Show current available heads in the script directory."""
    alembic.heads(
        _get_config(app),
        verbose=verbose,
        resolve_dependencies=resolve_dependencies,
    )
Beispiel #10
0
def heads(context,
          directory="migrations",
          verbose=False,
          resolve_dependencies=False):
    """新"""
    if alembic_version >= (0, 7, 0):
        config = _get_config(directory)
        command.heads(config,
                      verbose=verbose,
                      resolve_dependencies=resolve_dependencies)
    else:
        raise RuntimeError("Alembic 0.7.0 or greater is required")
Beispiel #11
0
    def heads(self, verbose=False):
        """
        Get heads

        :param verbose: additional information
        :return: Head Revisions
        """
        if verbose:
            command.heads(self.init_config, verbose=True)

        for head in self.script.get_heads():
            yield self.get_revision(head)
Beispiel #12
0
def head_database(revision_type):
    """Shows the heads of the database."""
    from alembic import command as alembic_command
    from alembic.config import Config as AlembicConfig

    alembic_cfg = AlembicConfig(config.ALEMBIC_INI_PATH)
    if revision_type == "core":
        path = config.ALEMBIC_CORE_REVISION_PATH

    elif revision_type == "tenant":
        path = config.ALEMBIC_TENANT_REVISION_PATH

    alembic_cfg.set_main_option("script_location", path)
    alembic_command.heads(alembic_cfg)
Beispiel #13
0
def heads(config, verbose: bool, resolve_dependencies: bool):
    """Show current available heads in the script directory."""

    bot = Bot(config)

    directory = os.path.join('yui', 'models', 'migrations')
    c = Config(os.path.join(directory, 'alembic.ini'))
    c.set_main_option('script_location', directory)
    c.set_main_option('sqlalchemy.url', bot.config.DATABASE_URL)
    c.attributes['Base'] = bot.orm_base

    command.heads(c,
                  verbose=verbose,
                  resolve_dependencies=resolve_dependencies)
 def heads(context,
           directory='migrations',
           verbose=False,
           resolve_dependencies=False):
     """Show current available heads in the script directory"""
     from app import create_app
     with create_app().app_context():
         if alembic_version >= (0, 7, 0):
             config = _get_config(directory)
             command.heads(config,
                           verbose=verbose,
                           resolve_dependencies=resolve_dependencies)
         else:
             raise RuntimeError('Alembic 0.7.0 or greater is required')
Beispiel #15
0
    def heads(self,
              verbose: bool = False,
              resolve_dependencies: bool = False) -> t.Any:
        config = self.configuration.to_alembic_config()

        return command.heads(config,
                             verbose=verbose,
                             resolve_dependencies=resolve_dependencies)
Beispiel #16
0
 def heads(self, verbose=None):
     command.heads(self.config, verbose=verbose)
Beispiel #17
0
def heads(opt, config):
    command.heads(config,
                  verbose=opt["--verbose"],
                  resolve_dependencies=opt["--resolve-dependencies"])
Beispiel #18
0
def heads(directory=None, verbose=False, resolve_dependencies=False):
    """Show current available heads in the script directory"""
    config = migrate_manager.migrate_config.migrate.get_config(directory)
    command.heads(config,
                  verbose=verbose,
                  resolve_dependencies=resolve_dependencies)
 def heads(self, directory=None, verbose=False, resolve_dependencies=False,
           **kwargs):  # pragma: no cover
     """Show current available heads in the script directory"""
     config = _get_config(directory)
     command.heads(config, verbose=verbose,
                   resolve_dependencies=resolve_dependencies)
Beispiel #20
0
elif args.user_promote is not None:
    session = SessionManager.Session()
    username = args.user_promote[0]
    level = int(args.user_promote[1])
    user = session.query(User).filter(User.name == username).one()
    user.level = level
    session.commit()
    print('Update successfully')
    SessionManager.Session.remove()

elif args.db_init:
    Base.metadata.create_all(SessionManager.engine)
    fp = StringIO()
    alembic_config = Config('./alembic.ini', stdout=fp)
    command.heads(alembic_config)
    content = fp.getvalue()
    fp.close()
    revision_hash = re.search('^([0-9a-f]+)\s\(head\)', content, re.U).group(1)
    print('set current revision {0}'.format(revision_hash))
    new_alembic_config = Config('./alembic.ini')
    command.stamp(new_alembic_config, revision=revision_hash)
    print('Database initialized')

elif args.cover:
    fr = open('./config/config.yml', 'r')
    config = yaml.load(fr)
    download_location = config['download']['location']
    session = SessionManager.Session()
    cur = session.query(Bangumi)
    resp_cookies = None
Beispiel #21
0
def heads(app, verbose=False, resolve_dependencies=False):
    """Show current available heads """
    command.heads(app.migrations_config, verbose=verbose,
                  resolve_dependencies=resolve_dependencies)
Beispiel #22
0
def heads(opt, config):
    command.heads(config, verbose=opt["--verbose"], resolve_dependencies=opt["--resolve-dependencies"])
Beispiel #23
0
def heads(directory=None, verbose=False, resolve_dependencies=False):
    """Show current available heads in the script directory"""
    config = current_app.extensions['migrate'].migrate.get_config(directory)
    command.heads(config,
                  verbose=verbose,
                  resolve_dependencies=resolve_dependencies)
 def heads(self, *_):
     """
     Show current available revision heads.
     """
     command.heads(self.config, verbose=True)
Beispiel #25
0
def heads() -> None:
    command.heads(alembic_cfg())
Beispiel #26
0
def head_database():
    """Shows the heads of the database."""
    alembic_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "alembic.ini")
    alembic_cfg = AlembicConfig(alembic_path)
    alembic_command.heads(alembic_cfg)
Beispiel #27
0
def heads(args, logger, baseguess):
    usable_modules, alembic_modules, alembic_config = alembic_setup(logger)
    from alembic import command
    command.heads(config=alembic_config,
                  verbose=(args.verbose == True),
                  resolve_dependencies=True)
 def heads(self, verbose=None):
     command.heads(self.config, verbose=verbose)
Beispiel #29
0
def heads(resolve_dependencies, verbose):
    """Show latest revisions."""

    command.heads(alembic_cfg, resolve_dependencies, verbose)