Skip to content

Commit 5399947

Browse files
committed
SQL: draft schema changes to support additional identifiers
1 parent 6bb8729 commit 5399947

File tree

1 file changed

+31
-0
lines changed
  • qiita_db/support_files/patches

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
-- Dec 12, 2025
2+
-- Adding SEQUENCEs and support tables for sample_idx, prep_sample_idx,
3+
-- and artifact_sample_idx
4+
5+
CREATE SEQUENCE sequence_sample_idx AS BIGINT;
6+
CREATE TABLE map_sample_idx (
7+
sample_name VARCHAR NOT NULL PRIMARY KEY,
8+
study_idx BIGINT NOT NULL,
9+
sample_idx BIGINT DEFAULT NEXTVAL('sequence_sample_idx') NOT NULL,
10+
UNIQUE (study_idx, sample_idx),
11+
UNIQUE (sample_idx),
12+
CONSTRAINT fk_study FOREIGN KEY (study_idx) REFERENCES qiita.study (study_id)
13+
);
14+
15+
CREATE SEQUENCE sequence_prep_sample_idx AS BIGINT;
16+
CREATE TABLE map_prep_sample_idx (
17+
prep_sample_idx BIGINT NOT NULL PRIMARY KEY DEFAULT NEXTVAL('sequence_prep_sample_idx'),
18+
prep_idx BIGINT NOT NULL,
19+
sample_idx BIGINT NOT NULL,
20+
UNIQUE (prep_idx, prep_sample_idx),
21+
CONSTRAINT fk_prep_template FOREIGN KEY (prep_idx) REFERENCES qiita.prep_template (prep_template_id)
22+
);
23+
24+
CREATE SEQUENCE sequence_artifact_sample_idx AS BIGINT;
25+
CREATE TABLE map_artifact_sample_idx (
26+
artifact_sample_idx BIGINT NOT NULL PRIMARY KEY DEFAULT NEXTVAL('sequence_artifact_sample_idx'),
27+
artifact_idx BIGINT NOT NULL,
28+
prep_sample_idx BIGINT NOT NULL,
29+
UNIQUE (artifact_idx, artifact_sample_idx),
30+
CONSTRAINT fk_artifact FOREIGN KEY (artifact_idx) REFERENCES qiita.artifact (artifact_id)
31+
);

0 commit comments

Comments
 (0)