Skip to content
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

Fix foreign key constraint in entries_data #665

Merged
merged 1 commit into from
Jan 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions store/sqlite/migrations/012-fix-entries_data-foreign-key.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- In migration 003, we didn't update entries_data to point to the new entries
-- table, so we have to fix it here. For some reason, the sqlite3 database
-- driver we were using at the time (mattn/go-sqlite3) didn't notice the
-- violation of the FOREIGN KEY constraint.
CREATE TABLE new_entries_data (
id TEXT,
chunk_index INTEGER,
chunk BLOB,
FOREIGN KEY (id) REFERENCES entries (id)
);

INSERT INTO new_entries_data
SELECT
id,
chunk_index,
chunk
FROM entries_data;

DROP TABLE entries_data;

ALTER TABLE new_entries_data RENAME TO entries_data;
Loading