Skip to content

Commit

Permalink
change the primary key to be more valid
Browse files Browse the repository at this point in the history
chunk ids should only be unique to users, not necessarily across the
whole server
  • Loading branch information
billyb2 committed Aug 18, 2024
1 parent c78b099 commit c3fd0b6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions migrations/20240818052859_better_primary_key.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE chunks RENAME CONSTRAINT chunks_pkey TO chunks_pkeyold;
CREATE UNIQUE INDEX chunks_pkey ON chunks (id, user_id);
ALTER TABLE chunks DROP CONSTRAINT chunks_pkeyold;
ALTER TABLE chunks ADD PRIMARY KEY USING INDEX chunks_pkey;
ALTER TABLE chunks ADD CONSTRAINT unique_id_user_id UNIQUE (id, user_id);

0 comments on commit c3fd0b6

Please sign in to comment.