[#46] MemberHistory: Add Type to PK

This commit is contained in:
2024-06-17 01:19:25 +02:00
parent b76c5ea874
commit 9d9f929843
4 changed files with 22 additions and 6 deletions

View File

@ -0,0 +1,16 @@
-- schema version 20 to 21
DROP TABLE member_history;
CREATE TABLE member_history (
mgnr INTEGER NOT NULL,
date TEXT NOT NULL CHECK (date REGEXP '^[1-9][0-9]{3}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$') DEFAULT CURRENT_DATE,
type TEXT NOT NULL CHECK (type REGEXP '^[a-z_]+$'),
business_shares INTEGER NOT NULL,
comment TEXT DEFAULT NULL,
CONSTRAINT pk_member_history PRIMARY KEY (mgnr, date, type),
CONSTRAINT fk_member_history_member FOREIGN KEY (mgnr) REFERENCES member (mgnr)
ON UPDATE CASCADE
ON DELETE CASCADE
) STRICT;