Skip to content

Commit

Permalink
SQL: Allow NULL values for annotation.last_revision_id
Browse files Browse the repository at this point in the history
  • Loading branch information
MonkeyDo committed Jul 17, 2024
1 parent 2315cb7 commit c484187
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions sql/migrations/2024-07-17-annotation-revision-id/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

BEGIN;

ALTER TABLE bookbrainz.annotation ALTER COLUMN last_revision_id SET NOT NULL;

COMMIT;
7 changes: 7 additions & 0 deletions sql/migrations/2024-07-17-annotation-revision-id/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Allow NULL values for annotation.last_revision_id (foreing key to revision table)
-- so that we can use annotations for entities pending import, which do not have revisions.
BEGIN;

ALTER TABLE bookbrainz.annotation ALTER COLUMN last_revision_id DROP NOT NULL;

COMMIT;
2 changes: 1 addition & 1 deletion sql/schemas/bookbrainz.sql
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ ALTER TABLE bookbrainz.work_revision ADD FOREIGN KEY (data_id) REFERENCES bookbr
CREATE TABLE bookbrainz.annotation (
id SERIAL PRIMARY KEY,
content TEXT NOT NULL,
last_revision_id INT NOT NULL
last_revision_id INT
);
ALTER TABLE bookbrainz.annotation ADD FOREIGN KEY (last_revision_id) REFERENCES bookbrainz.revision (id);
ALTER TABLE bookbrainz.author_data ADD FOREIGN KEY (annotation_id) REFERENCES bookbrainz.annotation (id);
Expand Down

0 comments on commit c484187

Please sign in to comment.