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
Since there is no "previous" version/schema for the first migration that is being run right after pgroll init, segv happens for column related changes such as adding unique constaint or a column; similar to #623
Having no previous version/schema might cause segv during Rollback, because it first tries to fetch the schema before the migration, in order to replay that migration on that schema. A similar issue that is happening when a sql command is run between migrations is fixed in #631 by taking inferred migrations into account. However, if the sql command is not added into migrations table, presumably because it is executed before pgroll init, pgroll wouldn't be able to find it.
To reproduce, first create a table:
createtableproducts (id serialprimary key, name varchar(255) unique, price decimal(10,2));
Add a GUC, something like pgroll.initial_schema, and load it with the output of read_schema during pgroll init. If no previous version is found when Rollback, use it.
Add a new column to pgroll.migrations, something like previous_schema. At the beginning of Start, call read_schema and save the output in that column when inserting current migration into migrations. If no previous version is found when Rollback, use it.
At the beginning of Start, call read_schema and save the output in column resulting_schema when inserting current migration into migrations. If no previous version is found when Rollback, use it.
The third option doesn't sound good because what we are inserting there is not a 'resulting' schema. Kind of a hacky way but it will be updated during Complete anyway if the migration doesn't Rollback, so it looks harmless. If a Rollback happens instead of Complete it will be first useful for this case, and then deleted, harmless again. It would also save us from having another column added to migrations.
The text was updated successfully, but these errors were encountered:
Since there is no "previous" version/schema for the first migration that is being run right after
pgroll init
, segv happens for column related changes such as adding unique constaint or a column; similar to #623Having no previous version/schema might cause segv during
Rollback
, because it first tries to fetch the schema before the migration, in order to replay that migration on that schema. A similar issue that is happening when a sql command is run between migrations is fixed in #631 by takinginferred
migrations into account. However, if the sql command is not added intomigrations
table, presumably because it is executed beforepgroll init
,pgroll
wouldn't be able to find it.To reproduce, first create a table:
Then:
Some candidate solutions:
pgroll.initial_schema
, and load it with the output ofread_schema
duringpgroll init
. If no previous version is found whenRollback
, use it.pgroll.migrations
, something likeprevious_schema
. At the beginning ofStart
, callread_schema
and save the output in that column when inserting current migration intomigrations
. If no previous version is found whenRollback
, use it.Start
, callread_schema
and save the output in columnresulting_schema
when inserting current migration intomigrations
. If no previous version is found whenRollback
, use it.The third option doesn't sound good because what we are inserting there is not a 'resulting' schema. Kind of a hacky way but it will be updated during
Complete
anyway if the migration doesn'tRollback
, so it looks harmless. If aRollback
happens instead ofComplete
it will be first useful for this case, and then deleted, harmless again. It would also save us from having another column added tomigrations
.The text was updated successfully, but these errors were encountered: