Python alembic.command.current() Examples

The following are 30 code examples of alembic.command.current(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module alembic.command , or try the search function .
Example #1
Source File: test_command.py    From alembic with MIT License 5 votes vote down vote up
def test_edit_no_current(self):
        assert_raises_message(
            util.CommandError,
            "No current revisions",
            command.edit,
            self.cfg,
            "current",
        ) 
Example #2
Source File: test_offline_environment.py    From alembic with MIT License 5 votes vote down vote up
def test_head_rev_post_context_multihead(self):
        d, e, f = multi_heads_fixture(self.cfg, a, b, c)
        env_file_fixture(
            """
context.configure(dialect_name='sqlite')
assert set(context.get_head_revisions()) == set(('%s', '%s', '%s', ))
"""
            % (e, f, c)
        )
        command.upgrade(self.cfg, e, sql=True)
        command.downgrade(self.cfg, "%s:%s" % (e, b), sql=True)
        command.stamp(self.cfg, c, sql=True)
        command.current(self.cfg) 
Example #3
Source File: test_command.py    From alembic with MIT License 5 votes vote down vote up
def test_history_current_to_head_as_b(self):
        command.stamp(self.cfg, self.b)
        self.cfg.stdout = buf = self._buf_fixture()
        command.history(self.cfg, "current:", verbose=True)
        self._eq_cmd_output(buf, [self.c, self.b], env_token=True) 
Example #4
Source File: test_command.py    From alembic with MIT License 5 votes vote down vote up
def test_history_current_to_head_as_base(self):
        command.stamp(self.cfg, "base")
        self.cfg.stdout = buf = self._buf_fixture()
        command.history(self.cfg, "current:", verbose=True)
        self._eq_cmd_output(buf, [self.c, self.b, self.a], env_token=True) 
Example #5
Source File: test_command.py    From alembic with MIT License 5 votes vote down vote up
def test_doesnt_create_alembic_version(self):
        command.current(self.cfg)
        engine = self.bind
        with engine.connect() as conn:
            is_false(_connectable_has_table(conn, "alembic_version", None)) 
Example #6
Source File: test_command.py    From alembic with MIT License 5 votes vote down vote up
def test_no_current(self):
        command.stamp(self.cfg, ())
        with self._assert_lines([]):
            command.current(self.cfg) 
Example #7
Source File: test_command.py    From alembic with MIT License 5 votes vote down vote up
def test_two_heads(self):
        command.stamp(self.cfg, ())
        command.stamp(self.cfg, (self.a1.revision, self.b1.revision))
        with self._assert_lines(["a1", "b1"]):
            command.current(self.cfg) 
Example #8
Source File: test_command.py    From alembic with MIT License 5 votes vote down vote up
def test_heads_one_is_dependent(self):
        command.stamp(self.cfg, ())
        command.stamp(self.cfg, (self.b2.revision,))
        with self._assert_lines(["a2", "b2"]):
            command.current(self.cfg) 
Example #9
Source File: test_command.py    From alembic with MIT License 5 votes vote down vote up
def test_heads_upg(self):
        command.stamp(self.cfg, (self.b2.revision,))
        command.upgrade(self.cfg, (self.b3.revision))
        with self._assert_lines(["a2", "b3"]):
            command.current(self.cfg) 
Example #10
Source File: test_offline_environment.py    From alembic with MIT License 5 votes vote down vote up
def test_head_rev_pre_context_multihead(self):
        d, e, f = multi_heads_fixture(self.cfg, a, b, c)
        env_file_fixture(
            """
assert set(context.get_head_revisions()) == set(('%s', '%s', '%s', ))
"""
            % (e, f, c)
        )
        command.upgrade(self.cfg, e, sql=True)
        command.downgrade(self.cfg, "%s:%s" % (e, b), sql=True)
        command.stamp(self.cfg, c, sql=True)
        command.current(self.cfg) 
Example #11
Source File: test_command.py    From alembic with MIT License 5 votes vote down vote up
def test_edit_current(self):
        expected_call_arg = os.path.normpath(
            "%s/scripts/versions/%s_revision_b.py"
            % (EditTest.cfg.config_args["here"], EditTest.b)
        )

        command.stamp(self.cfg, self.b)
        with mock.patch("alembic.util.edit") as edit:
            command.edit(self.cfg, "current")
            edit.assert_called_with(expected_call_arg) 
Example #12
Source File: commands.py    From sgx-kms with Apache License 2.0 5 votes vote down vote up
def current(verbose, sql_url=None):
    alembic_cfg = init_config(sql_url)
    alembic_command.current(alembic_cfg, verbose=verbose) 
Example #13
Source File: commands.py    From barbican with Apache License 2.0 5 votes vote down vote up
def current(verbose, sql_url=None):
    alembic_cfg = init_config(sql_url)
    alembic_command.current(alembic_cfg, verbose=verbose) 
Example #14
Source File: alembic_wrapper.py    From build-relengapi with Mozilla Public License 2.0 5 votes vote down vote up
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) 
Example #15
Source File: alembic_wrapper.py    From build-relengapi with Mozilla Public License 2.0 5 votes vote down vote up
def branches(self, directory=None, verbose=False, **kwargs):  # pragma: no cover
        """Show current branch points"""
        config = _get_config(directory)
        command.branches(config, verbose=verbose) 
Example #16
Source File: alembic_wrapper.py    From build-relengapi with Mozilla Public License 2.0 5 votes vote down vote up
def make_parser(self, subparsers):
        parser = subparsers.add_parser('current', help=self.current.__doc__)
        parser.add_argument('--head-only', dest='head_only', action='store_true',
                            default=False,
                            help='Deprecated. Use --verbose for additional output')
        parser.add_argument('-v', '--verbose', dest='verbose', action='store_true',
                            default=False, help='Use more verbose output')
        parser.add_argument('-d', '--directory', dest='directory', default=None,
                            help=("migration script directory (default is "
                                  "'migrations')"))
        return parser 
Example #17
Source File: alembic_wrapper.py    From build-relengapi with Mozilla Public License 2.0 5 votes vote down vote up
def run(self, parser, args):
        self.current(**vars(args)) 
Example #18
Source File: alembic_wrapper.py    From build-relengapi with Mozilla Public License 2.0 5 votes vote down vote up
def current(self, directory=None, verbose=False, head_only=False, **kwargs):  # pragma: no cover
        """Display the current revision for each database."""
        config = _get_config(directory)
        command.current(config, verbose=verbose, head_only=head_only) 
Example #19
Source File: db.py    From flask-restplus-server-example with MIT License 5 votes vote down vote up
def edit(context, revision='current', directory='migrations'):
    """Upgrade to a later version"""
    if alembic_version >= (0, 8, 0):
        config = _get_config(directory)
        command.edit(config, revision)
    else:
        raise RuntimeError('Alembic 0.8.0 or greater is required') 
Example #20
Source File: __init__.py    From jbox with MIT License 5 votes vote down vote up
def heads(directory=None, verbose=False, resolve_dependencies=False):
    """Show current available heads in the script directory"""
    if alembic_version >= (0, 7, 0):
        config = current_app.extensions['migrate'].migrate.get_config(
            directory)
        command.heads(config, verbose=verbose,
                      resolve_dependencies=resolve_dependencies)
    else:
        raise RuntimeError('Alembic 0.7.0 or greater is required') 
Example #21
Source File: __init__.py    From jbox with MIT License 5 votes vote down vote up
def branches(directory=None, verbose=False):
    """Show current branch points"""
    config = current_app.extensions['migrate'].migrate.get_config(directory)
    if alembic_version >= (0, 7, 0):
        command.branches(config, verbose=verbose)
    else:
        command.branches(config) 
Example #22
Source File: __init__.py    From jbox with MIT License 5 votes vote down vote up
def current(directory=None, verbose=False, head_only=False):
    """Display the current revision for each database."""
    config = current_app.extensions['migrate'].migrate.get_config(directory)
    if alembic_version >= (0, 7, 0):
        command.current(config, verbose=verbose, head_only=head_only)
    else:
        command.current(config) 
Example #23
Source File: cli.py    From yui with GNU Affero General Public License v3.0 5 votes vote down vote up
def edit(config, revision: str):
    """Edit current revision."""

    bot = Bot(config)

    directory = os.path.join('yui', '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.edit(c, revision) 
Example #24
Source File: cli.py    From yui with GNU Affero General Public License v3.0 5 votes vote down vote up
def heads(config, verbose: bool, resolve_dependencies: bool):
    """Show current available heads in the script directory."""

    bot = Bot(config)

    directory = os.path.join('yui', '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
    ) 
Example #25
Source File: cli.py    From yui with GNU Affero General Public License v3.0 5 votes vote down vote up
def branches(config, verbose: bool):
    """Show current branch points."""

    bot = Bot(config)

    directory = os.path.join('yui', '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.branches(c, verbose=verbose) 
Example #26
Source File: cli.py    From yui with GNU Affero General Public License v3.0 5 votes vote down vote up
def current(config, verbose: bool):
    """Display the current revision for each database."""

    bot = Bot(config)

    directory = os.path.join('yui', '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.current(c, verbose=verbose) 
Example #27
Source File: admin.py    From kansha with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def run(parser, options, args):
        if len(args) not in (0, 1):
            parser.error('Bad number of parameters')

        # Read the configuration of the application
        try:
            application = args[0]
        except IndexError:
            application = 'kansha'

        cfg = _build_alembic_config()
        _set_sqlalchemy_uri(cfg, application, parser.error)

        command.current(cfg, verbose=options.verbose) 
Example #28
Source File: __init__.py    From jbox with MIT License 5 votes vote down vote up
def edit(revision='current', directory=None):
    """Edit current revision."""
    if alembic_version >= (0, 8, 0):
        config = current_app.extensions['migrate'].migrate.get_config(
            directory)
        command.edit(config, revision)
    else:
        raise RuntimeError('Alembic 0.8.0 or greater is required') 
Example #29
Source File: db.py    From flask-restplus-server-example with MIT License 5 votes vote down vote up
def heads(context, directory='migrations', 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') 
Example #30
Source File: db.py    From flask-restplus-server-example with MIT License 5 votes vote down vote up
def branches(context, directory='migrations', verbose=False):
    """Show current branch points"""
    config = _get_config(directory)
    if alembic_version >= (0, 7, 0):
        command.branches(config, verbose=verbose)
    else:
        command.branches(config)