vocdoni-node icon indicating copy to clipboard operation
vocdoni-node copied to clipboard

bug: sql migration PR #566

Open jordipainan opened this issue 2 years ago • 8 comments

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.

jordipainan avatar Jul 18 '22 14:07 jordipainan

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

p4u avatar Sep 21 '22 10:09 p4u

Sort of, this is a minor mistake in https://github.com/vocdoni/vocdoni-node/pull/596/files#diff-eec79c6c2d91658d1798414cefcef32d77974afe15429b2e49b9ffcd872b8be8. Looking.

mvdan avatar Sep 21 '22 10:09 mvdan

@p4u please try https://github.com/vocdoni/vocdoni-node/pull/605.

mvdan avatar Sep 21 '22 10:09 mvdan

Works @mvdan @jordipainan is there anything else on this issue?

p4u avatar Sep 21 '22 12:09 p4u

nope! closing it

jordipainan avatar Sep 22 '22 12:09 jordipainan

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 ?

jordipainan avatar Sep 23 '22 09:09 jordipainan

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.

mvdan avatar Sep 23 '22 09:09 mvdan

@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 ?

jordipainan avatar Sep 23 '22 10:09 jordipainan

@p4u recently mentioned we're breaking backwards compatibility, so it sounds like we don't really care about existing DBs :)

mvdan avatar Jan 23 '23 17:01 mvdan