Closed expipiplus1 closed 7 years ago
Perhaps I've misunderstood how to use this library, but I've got a list of MigrationCommands which I'm sequencing over during program startup, the first of which is MigrationInitialization.
The idea is to run the initialisation only once when you bootstrap your application the first time.
Afterwards you can use MigrationValidation
to validate the database state and apply your migrations.
The idea is to run the initialisation only once when you bootstrap your application the first time.
I was hoping that the absence of schema_migrations
could be an indication that this is being run for the first time.
I suppose I could always do SET LOCAL client_min_messages TO warning;
in the transaction.
At the moment I can't imagine a situation where I wouldn't want to apply any remaining migrations upon discovering (with MigrationValidation
) that the database isn't at the latest version.
Reading the source it seems as though the correct way to test for schema_migrations
would be to run MigrationValidation MigrationInitialization
.
Reading the source it seems as though the correct way to test for schema_migrations would be to run MigrationValidation MigrationInitialization.
Exactly.
Checking for the existence of schema_migrations via MigrationValidation MigrationInitialization
doesn't work as existsTable function seems broken.
The SQL-Query select count(relname) from pg_class where relname = ?
always returns a row and therefor checking the lists length always indicates the tables existence, which is wrong.
The queries result (always one row) should be numerically compared to 0 not if there is a row returned.
Thanks for the bug report!
It's fixed in 0a1a1bba081618e9575123fd5f371d997e96f154 and release 0.1.11.0.
That was quick, thanks!
When
MigrationInitialization
is run whenschema_migrations
already exists it prints outNOTICE: relation "schema_migrations" already exists, skipping
.Perhaps I've misunderstood how to use this library, but I've got a list of
MigrationCommand
s which I'm sequencing over during program startup, the first of which isMigrationInitialization
.