Add occurrence checklist submodule

This commit is contained in:
gitea_admin committed 2026-09-30 10:08:48 +02:00
1 parent 5dbbac35c3
commit f9b5383ae9
12 files changed
+254 -2

No files matched your search

@@ -0,0 +1,33 @@
BEGIN;
CREATE TABLE market_occurrence_checklist (
id BIGSERIAL PRIMARY KEY,
occurrence_id BIGINT NOT NULL UNIQUE REFERENCES market_occurrence(id) ON DELETE RESTRICT,
comment TEXT,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW()
);
CREATE TABLE market_occurrence_checklist_item (
id BIGSERIAL PRIMARY KEY,
occurrence_id BIGINT NOT NULL REFERENCES market_occurrence(id) ON DELETE RESTRICT,
position INTEGER NOT NULL,
label TEXT NOT NULL,
is_completed BOOLEAN NOT NULL DEFAULT FALSE,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
CONSTRAINT chk_market_occurrence_checklist_item_position CHECK (position > 0)
);
CREATE INDEX idx_market_occurrence_checklist_item_occurrence
ON market_occurrence_checklist_item(occurrence_id, position, id);
INSERT INTO market_occurrence_checklist (occurrence_id)
SELECT id FROM market_occurrence;
INSERT INTO market_occurrence_checklist_item (occurrence_id, position, label)
SELECT occurrence_id, position, 'Position ' || position
FROM market_occurrence_checklist
CROSS JOIN generate_series(1, 30) AS positions(position);
COMMIT;