Skip to content

Commit

Permalink
Remove extraneous fields from primary keys for relation members
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Oct 10, 2023
1 parent 5458691 commit f0a5dde
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
11 changes: 11 additions & 0 deletions db/migrate/20231010194809_correct_relation_members_primary_key.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class CorrectRelationMembersPrimaryKey < ActiveRecord::Migration[7.0]
def up
alter_primary_key :current_relation_members, [:relation_id, :sequence_id]
alter_primary_key :relation_members, [:relation_id, :version, :sequence_id]
end

def down
alter_primary_key :relation_members, [:relation_id, :version, :member_type, :member_id, :member_role, :sequence_id]
alter_primary_key :current_relation_members, [:relation_id, :member_type, :member_id, :member_role, :sequence_id]
end
end
5 changes: 3 additions & 2 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1875,7 +1875,7 @@ ALTER TABLE ONLY public.current_nodes
--

ALTER TABLE ONLY public.current_relation_members
ADD CONSTRAINT current_relation_members_pkey PRIMARY KEY (relation_id, member_type, member_id, member_role, sequence_id);
ADD CONSTRAINT current_relation_members_pkey PRIMARY KEY (relation_id, sequence_id);


--
Expand Down Expand Up @@ -2099,7 +2099,7 @@ ALTER TABLE ONLY public.redactions
--

ALTER TABLE ONLY public.relation_members
ADD CONSTRAINT relation_members_pkey PRIMARY KEY (relation_id, version, member_type, member_id, member_role, sequence_id);
ADD CONSTRAINT relation_members_pkey PRIMARY KEY (relation_id, version, sequence_id);


--
Expand Down Expand Up @@ -3466,6 +3466,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20230825162137'),
('20230830115219'),
('20230830115220'),
('20231010194809'),
('21'),
('22'),
('23'),
Expand Down

0 comments on commit f0a5dde

Please sign in to comment.