You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Imagine a project with its migrations, and it has its command to apply it. Now, you have installed library foo that applies migrations also with its CLI (knowing that the library has the flag IgnoreUnknown set to true when applying its migrations).
Problem
If you apply the project migrations and then try to run the migrations for the library, sql-migrate will consider that all migrations from the library were already applied since it does not consider the IgnoreUnknown flag when getting the record that contains the last applied migration:
It's possible to use the migrate.SetTable to change the migrations table name for the library or the project. But, I'd recommend using the migrate.MigrationSet{TableName: "my_library_migrations"} struct locally to avoid changing the singleton of the library because it's error-prone.
// sql-migrate version 1.3.1ms:= migrate.MigrationSet{TableName: "my_library_migrations"}
m:= migrate.HttpFileSystemMigrationSource{FileSystem: http.FS(migrations.FS)}
ms.ExecMax(db, "postgres", m, migrate.Up, 1)
Context
Imagine a
project
with its migrations, and it has its command to apply it. Now, you have installed libraryfoo
that applies migrations also with its CLI (knowing that the library has the flagIgnoreUnknown
set totrue
when applying its migrations).Problem
If you apply the
project
migrations and then try to run the migrations for thelibrary
,sql-migrate
will consider that all migrations from the library were already applied since it does not consider theIgnoreUnknown
flag when getting therecord
that contains the last applied migration:https://github.com/rubenv/sql-migrate/blob/master/migrate.go#L609-L613
It results in not applying the library migrations.
Example
It shouldn't print an empty array since none of the Library migrations was applied.
Expect
I expect the library's migrations to be applied.
The text was updated successfully, but these errors were encountered: