How to use the muffin.plugins.peewee.migrate.MigrateHistory function in muffin

To help you get started, we’ve selected a few muffin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github klen / muffin / muffin / plugins / peewee / migrate.py View on Github external
def model(self):
        """ Ensure that migrations has prepared to run. """
        # Initialize MigrationHistory model
        MigrateHistory._meta.database = self.app.plugins.peewee.database
        try:
            MigrateHistory.create_table()
        except pw.OperationalError:
            pass
        return MigrateHistory
github klen / muffin / muffin / plugins / peewee / __init__.py View on Github external
""" Initialize the application. """
        super().setup(app)
        if 'manage' not in app.plugins:
            raise PluginException('Peewee plugin requires Manage plugin initialized before.')

        # Setup Database
        self.database.initialize(connect(self.options['connection']))
        self.threadpool = concurrent.futures.ThreadPoolExecutor(
            max_workers=self.options['max_connections'])

        if not self.options.migrations_enabled:
            return

        # Setup migration engine
        self.router = Router(self)
        self.register(MigrateHistory)

        # Register migration commands
        @self.app.ps.manage.command
        def migrate(name:str=None):
            """ Run application's migrations.

            :param name: Choose a migration' name

            """
            self.router.run(name)

        @self.app.ps.manage.command
        def create(name:str):
            """ Create a migration.

            :param name: Set name of migration [auto]
github klen / muffin / muffin / plugins / peewee / migrate.py View on Github external
def model(self):
        """ Ensure that migrations has prepared to run. """
        # Initialize MigrationHistory model
        MigrateHistory._meta.database = self.app.plugins.peewee.database
        try:
            MigrateHistory.create_table()
        except pw.OperationalError:
            pass
        return MigrateHistory
github klen / muffin / muffin / plugins / peewee / migrate.py View on Github external
def model(self):
        """ Ensure that migrations has prepared to run. """
        # Initialize MigrationHistory model
        MigrateHistory._meta.database = self.app.plugins.peewee.database
        try:
            MigrateHistory.create_table()
        except pw.OperationalError:
            pass
        return MigrateHistory