vocdoni-node
vocdoni-node copied to clipboard
bug: sql migration PR #566
PR #566 caused the DB to not make properly the migration and new columns were not created.
Migration 1 needs to be migration 2 and the use of an ALTER_TABLE.
Is this related?
2022-09-21T10:18:18Z INFO scrutinizer/scrutinizer.go:130 indexer initialization took 368.206µs, stored 2342 transactions, 880 envelopes, 272 processes and 86 entities
2022-09-21T10:18:18Z FATAL dvotenode/dvotenode.go:524 goose up: ERROR 0003_alter_table_processes_votes.sql: failed to run SQL migration: failed to execute SQL query "ALTER TABLE vote_references ADD voter_id BLOB NOT NULL;\n": Cannot add a NOT NULL column with default value NULL
I need fix for this issue ASAP if possible @jordipainan @mvdan
Sort of, this is a minor mistake in https://github.com/vocdoni/vocdoni-node/pull/596/files#diff-eec79c6c2d91658d1798414cefcef32d77974afe15429b2e49b9ffcd872b8be8. Looking.
@p4u please try https://github.com/vocdoni/vocdoni-node/pull/605.
Works @mvdan @jordipainan is there anything else on this issue?
nope! closing it
FATAL dvotenode/dvotenode.go:524 goose up: ERROR 0003_alter_table_processes_votes.sql: failed to run SQL migration: failed to execute SQL query "ALTER TABLE processes ADD results_votes TEXT NOT NULL DEFAULT '';\n": duplicate column name: results_votes
migration still fails while testing on dev network
cc: @mvdan
Maybe the migration is not possible due to the hardcoded values on migration 2 and we need to restart the db ?
Hm, yeah. If any DB was created or upgraded with the previous bad migration sequence, then it's broken for good. That's my bad. The easiest solution is indeed to restart the DB.
If the DB contained important data, what we could do is manually fix up the migration version embedded in the SQL database to change it from 2 to 3. But that's probably not worth the hassle if we can restart the DB.
@p4u in production we will need to restart the db too, but as the nodes can recreate everything, do you think it makes sense to just go ahead with the approach of restarting the dbs ?
@p4u recently mentioned we're breaking backwards compatibility, so it sounds like we don't really care about existing DBs :)