-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: adding extra migration to sqlite and improving error message #3240
Conversation
You can find the image built from this PR at
Built from 8b6a435 |
ALTER TABLE message DROP COLUMN timestamp; | ||
|
||
ALTER TABLE message RENAME COLUMN storedAt TO timestamp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copying the following migration we do for Postgres:
-- we can drop the timestamp column because this data is also kept in the storedAt column | |
ALTER TABLE messages DROP COLUMN timestamp; | |
-- from now on we are only interested in the message timestamp | |
ALTER TABLE messages RENAME COLUMN storedAt TO timestamp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thanks for it! 💯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you!
@@ -0,0 +1,3 @@ | |||
ALTER TABLE message DROP COLUMN timestamp; | |||
|
|||
ALTER TABLE message RENAME COLUMN storedAt TO timestamp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh this is cool.
I thought renaming columns in sqlite wasn't possible but required creating a new table with the new column name and migrating the data from the old table to the new one!
Is this a feature that was added recently? (for sure it would be useful even for status since there we do the 'manual' renaming procedure i mentioned).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question! Not sure if it's a recent honestly, I just copied it from the migration script we use in postgres and it worked lol
It does seem it's a feature supported by sqlite: https://www.sqlitetutorial.net/sqlite-rename-column/
update: the article does say "SQLite did not support the ALTER TABLE RENAME COLUMN syntax before version 3.25.0."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was introduced in 2018! wow!
Description
Waku Archive with sqlite was broken, as our table required a
storedAt
column being not null, and we are not using that column anymore, so insert statements were failing.The tests didn't catch the issue because migrations weren't executed before the tests, so the tests were run with a db schema that wasn't the one our nodes were using in practice.
Fixed issue executing insert statements and modified tests in order to catch similar issues in the future
Changes
storedAt
column withtimestamp
Issue
#3236