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

Add begin date and end date attribute to relationship #1073

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
118 changes: 118 additions & 0 deletions sql/migrations/2024-03-01-date-relationship-attribute/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
BEGIN;

INSERT INTO bookbrainz.relationship_attribute_type (id, parent, root, child_order, name, description)
VALUES
(3, NULL, 1, 0, 'Begin date', 'This attribute indicates when the relationship begin.'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(3, NULL, 1, 0, 'Begin date', 'This attribute indicates when the relationship begin.'),
(3, NULL, 1, 0, 'Begin date', 'This attribute indicates when the relationship began.'),

Comment on lines +3 to +5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you can omit the id, as it is defined to be of type SERIAL in the SQL schema, it will be automatically incremented (and will avoid potential conflicts if the script was run out of order):

Suggested change
INSERT INTO bookbrainz.relationship_attribute_type (id, parent, root, child_order, name, description)
VALUES
(3, NULL, 1, 0, 'Begin date', 'This attribute indicates when the relationship begin.'),
INSERT INTO bookbrainz.relationship_attribute_type (parent, root, child_order, name, description)
VALUES
(NULL, 1, 0, 'Begin date', 'This attribute indicates when the relationship begin.'),

(4, NULL, 1, 0, 'End date', 'This attribute indicates when the relationship ended.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above:
Plus we can defined a child_order here (I don't think it's currently in use on the website, but for the future it allows sorting siblings):

Suggested change
(4, NULL, 1, 0, 'End date', 'This attribute indicates when the relationship ended.');
(NULL, 1, 1, 'End date', 'This attribute indicates when the relationship ended.');





INSERT INTO bookbrainz.relationship_type__attribute_type (relationship_type, attribute_type)
VALUES
-- Author --
(8, 3),
(8, 4),

-- Marriage --
(11,3),
(11,4),

-- Involved with --
(12,3),
(12,4),

-- Member of Group --
(13,3),
(13,4),

-- Subgroup --
(16,3),
(16,4),

-- Collaboration --
(19,3),
(19,4),

-- translated --
(9,3),
(9,4),

-- Adaptor --
(62,3),
(62,4),

-- Worked On --
(1,3),
(1,4),

-- Artist --
(33,3),
(33,4),

-- Illustrator --
(2,3),
(2,4),
(29,3),
(29,4),

-- Photographer --
(26,3),
(26,4),
(59,3),
(59,4),

-- Penciller --
(60,3),
(60,4),

-- Colourist --
(61,3),
(61,4),

-- Inker --
(30,3),
(30,4),

-- Letterer --
(32,3),
(32,4),

-- Other --
(58,3),
(58,4),

-- Editor --
(5,3),
(5,4),

-- Proofreader --
(22,3),
(22,4),

-- Compiler --
(23,3),
(23,4),

-- Designer --
(24,3),
(24,4),

-- Blurb --
(27,3),
(27,4),

-- Art Director --
(28,3),
(28,4),

-- Employee --
(21,3),
(21,4);


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few suggested additions, after looking more closely at the relationship_type table:

  • 18, 90 -> Pen name, Persona
  • 35, 69 -> Reconstruction
  • 36 -> Previous attribution
  • 40 -> Owner (publishers)
  • 41 -> Renamed (publishers)
  • 44, 63 -> Copyright
  • 45, 46 & 51 -> Licensor, Licensee
  • 57 -> Reprint





COMMIT;
117 changes: 117 additions & 0 deletions sql/schemas/bookbrainz.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1055,4 +1055,121 @@ CREATE VIEW bookbrainz.work_import AS
LEFT JOIN bookbrainz.alias_set alias_set ON work_data.alias_set_id = alias_set.id
WHERE import.type = 'Work';


INSERT INTO bookbrainz.relationship_attribute_type (id, parent, root, child_order, name, description)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should not be changed in this case.
We modify it when we add or modify a table or something like that, but not when we add rows of data to the database, that is why we have separate migration scripts.
So you can remove all these additions in bookbrainz.sql

VALUES
(3, NULL, 1, 0, 'Begin date', 'This attribute indicates when the relationship begin.'),
(4, NULL, 1, 0, 'End date', 'This attribute indicates when the relationship ended.');




INSERT INTO bookbrainz.relationship_type__attribute_type (relationship_type, attribute_type)
VALUES
-- Author --
(8, 3),
(8, 4),

-- Marriage --
(11,3),
(11,4),

-- Involved with --
(12,3),
(12,4),

-- Member of Group --
(13,3),
(13,4),

-- Subgroup --
(16,3),
(16,4),

-- Collaboration --
(19,3),
(19,4),

-- translated --
(9,3),
(9,4),

-- Adaptor --
(62,3),
(62,4),

-- Worked On --
(1,3),
(1,4),

-- Artist --
(33,3),
(33,4),

-- Illustrator --
(2,3),
(2,4),
(29,3),
(29,4),

-- Photographer --
(26,3),
(26,4),
(59,3),
(59,4),

-- Penciller --
(60,3),
(60,4),

-- Colourist --
(61,3),
(61,4),

-- Inker --
(30,3),
(30,4),

-- Letterer --
(32,3),
(32,4),

-- Other --
(58,3),
(58,4),

-- Editor --
(5,3),
(5,4),

-- Proofreader --
(22,3),
(22,4),

-- Compiler --
(23,3),
(23,4),

-- Designer --
(24,3),
(24,4),

-- Blurb --
(27,3),
(27,4),

-- Art Director --
(28,3),
(28,4),

-- Employee --
(21,3),
(21,4);







COMMIT;
Loading