I'm running migrations programmatically by using this snippet in a file "cli.py":
repository = DatabaseMigrationRepository(self.db, self.migrations_table)
migrator = Migrator(repository, self.db)
if not migrator.repository_exists():
repository.create_repository()
migrator.set_connection("postgres")
migrator.run(self.migrations_path, pretend)
This was running fine until today when I was forced to create everything in a different schema than "public".
So I changed all table names by prepending the schema name "sih". I also needed to change the name of the "migrations" table to "sih.migrations". This seems to work, but only once. When calling it a 2nd time to execute another migration, I'm getting this error:
❯ python3 cli.py migrate ... --migrations-table=sih.migrations
DEBUG:orator.database_manager:Initiating connection postgres
DEBUG:orator.database_manager:Making connection for postgres
DEBUG:orator.database_manager:Preparing connection postgres
FEHLER: Relation »migrations« existiert bereits
(SQL: CREATE TABLE "sih"."migrations" ("migration" VARCHAR(255) NOT NULL, "batch" INTEGER NOT NULL) (None))Cannot execute migrations
It says "ERROR: Relation »migrations« already exists".
Moin,
I'm running migrations programmatically by using this snippet in a file "cli.py":
This was running fine until today when I was forced to create everything in a different schema than "public".
So I changed all table names by prepending the schema name "sih". I also needed to change the name of the "migrations" table to "sih.migrations". This seems to work, but only once. When calling it a 2nd time to execute another migration, I'm getting this error:
It says "ERROR: Relation »migrations« already exists".
Before renaming everything it worked fine.