Closed enobayram closed 1 year ago
Here's how I've verified this PR:
chainweb-data
once and made it create the schema_migrations
table.$ /nix/store/gfly46vsbkxjvmf6c42nfc80b6x91irk-chainweb-data-2.0.1/bin/chainweb-data ... fill
...
2022-12-09T14:46:17.368Z [Info] [] No database migration needed. Continuing...
2022-12-09T14:46:17.368Z [Info] [] Adding height index on transactions table
NOTICE: relation "transactions_height_idx" already exists, skipping
2022-12-09T14:46:17.368Z [Info] [] Adding (height, chainid, idx) index on events table
NOTICE: relation "events_height_chainid_idx" already exists, skipping
2022-12-09T14:46:17.369Z [Info] [] Adding "(height,name,(params ->> 0),(params ->> 1)) WHERE name = 'TRANSFER'" index
NOTICE: relation "events_height_name_expr_expr1_idx" already exists, skipping
2022-12-09T14:46:17.369Z [Info] [] Adding "(from_acct, height desc, idx)" index on transfers table
NOTICE: relation "transfers_from_acct_height_idx" already exists, skipping
2022-12-09T14:46:17.369Z [Info] [] Adding "(to_acct, height desc,idx)" index on transfers table
NOTICE: relation "transfers_to_acct_height_idx_idx" already exists, skipping
2022-12-09T14:46:17.369Z [Info] [] Adding "(requestkey)" index on transactions table
NOTICE: relation "transactions_requestkey_idx" already exists, skipping
2022-12-09T14:46:17.370Z [Info] [] Adding "(requestkey)" index on events table
NOTICE: relation "events_requestkey_idx" already exists, skipping
2022-12-09T14:46:17.370Z [Info] [] Initializing the incremental migrations table
NOTICE: relation "schema_migrations" already exists, skipping
2022-12-09T14:46:17.370Z [Info] [] Initialized migrations
2022-12-09T14:46:17.370Z [Info] [] DB Tables Initialized
...
You can see in the output that it's reporting "No database migration needed" even though the "Initializing the incremental migrations table" step indicates that relation "schema_migrations" already exists.
In preparation for switching to the script-based migration, we've added the creation of the schema_migrations table to the cw-data start up. However, when we add that table, the next time we start chainweb-data it complains about the need to remove that table, which is obviously not something we intend to do.
This PR filters the calculated migration steps and removes any "TableRemove" step. Note that this should avoid the spurious "DROP schema_migrations" error when the database is otherwise fully migrated, but if there are any additional migrations required, cw-data will still try to perform those migrations using tryRunMigrationsWithEditUpdate, which will in turn error out due to the spurious TableRemove steps. However, since this is supposed to be the final version of cw-data that will perform migrations with beam-automigrate, our users shouldn't ever run into that problem.