Skip to content

Commit 912c18e

Browse files
Merge pull request #606 from sgrif/sg-crate-owners-schema
Remove pointless column and index from `crate_owners`
2 parents 35d2240 + 02fe809 commit 912c18e

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ALTER TABLE crate_owners DROP CONSTRAINT crate_owners_pkey;
2+
ALTER TABLE crate_owners ADD CONSTRAINT crate_owners_unique_owner_per_crate UNIQUE (crate_id, owner_id, owner_kind);
3+
ALTER TABLE crate_owners ADD COLUMN id SERIAL PRIMARY KEY;
4+
CREATE INDEX index_crate_owners_crate_id ON crate_owners (crate_id);
5+
DROP INDEX crate_owners_not_deleted;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ALTER TABLE crate_owners DROP COLUMN id;
2+
ALTER TABLE crate_owners DROP CONSTRAINT crate_owners_unique_owner_per_crate;
3+
ALTER TABLE crate_owners ADD PRIMARY KEY (crate_id, owner_id, owner_kind);
4+
DROP INDEX index_crate_owners_crate_id;
5+
CREATE UNIQUE INDEX crate_owners_not_deleted ON crate_owners (crate_id, owner_id, owner_kind) WHERE NOT deleted;

src/schema.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ table! {
3030
}
3131

3232
table! {
33-
crate_owners (id) {
34-
id -> Int4,
33+
crate_owners (crate_id, owner_id, owner_kind) {
3534
crate_id -> Int4,
3635
owner_id -> Int4,
3736
created_at -> Timestamp,

0 commit comments

Comments
 (0)