def create_system_database(self, engine_uri):
        click.secho(f"Creating system database...", fg="blue")
        # register the system database connection
        engine, _ = project_engine(self.project, engine_uri, default=True)

        migration_service = MigrationService(engine)
        migration_service.upgrade()
        migration_service.seed(self.project)
Example #2
0
    def migrate_database(self):
        click.secho("Applying migrations to system database...", fg="blue")

        try:
            migration_service = MigrationService(self.engine)
            migration_service.upgrade()
            migration_service.seed(self.project)
        except MigrationError as err:
            raise UpgradeError(str(err)) from err
Example #3
0
    def create_system_database(self):
        click.secho(f"Creating system database...", fg="blue")
        # register the system database connection
        engine_uri = f"sqlite:///{self.project.root}/.meltano/meltano.db"
        engine, _ = project_engine(self.project, engine_uri, default=True)

        migration_service = MigrationService(engine)
        migration_service.upgrade()
        migration_service.seed(self.project)
Example #4
0
def vacuum_db(engine_sessionmaker, project):
    engine, _ = engine_sessionmaker

    # ensure we delete all the tables
    metadata = MetaData(bind=engine)
    metadata.reflect()
    metadata.drop_all()

    # migrate back up
    migration_service = MigrationService(engine)
    migration_service.upgrade()
    migration_service.seed(project)
Example #5
0
        def decorate(engine_uri, *args, **kwargs):
            ctx = click.globals.get_current_context()

            project = ctx.obj["project"]
            if not project:
                raise click.ClickException(
                    f"`{ctx.command_path}` must be run inside a Meltano project."
                    "\nUse `meltano init <project_name>` to create one.")

            # register the system database connection
            engine, _ = project_engine(project, engine_uri, default=True)

            if self.migrate:
                migration_service = MigrationService(engine)
                migration_service.upgrade()
                migration_service.seed(project)

            func(project, *args, **kwargs)
Example #6
0
        def decorate(*args, **kwargs):
            ctx = click.globals.get_current_context()

            project = ctx.obj["project"]
            if not project:
                raise CliError(
                    f"`{ctx.command_path}` must be run inside a Meltano project."
                    "\nUse `meltano init <project_name>` to create one."
                    "\nIf you are in a project, you may be in a subfolder. Navigate to the root directory."
                )

            # register the system database connection
            engine, _ = project_engine(project, default=True)

            if self.migrate:
                migration_service = MigrationService(engine)
                migration_service.upgrade(silent=True)
                migration_service.seed(project)

            func(project, *args, **kwargs)
Example #7
0
 def __init__(
     self, engine, project: Project, migration_service: MigrationService = None
 ):
     self.project = project
     self.migration_service = migration_service or MigrationService(engine)
Example #8
0
    def migrate_database(self):
        click.secho("Applying migrations to system database...", fg="blue")

        migration_service = MigrationService(self.engine)
        migration_service.upgrade()
        migration_service.seed(self.project)