[feat] add initial database schema with tables, triggers, and views

This commit is contained in:
2025-08-21 00:22:03 +02:00
parent 31af27f515
commit b8f33e252a
68 changed files with 882 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
create table requirement
(
id INTEGER
primary key,
owner_kind TEXT not null,
owner_id INTEGER not null,
group_no INTEGER default 1 not null,
negate INTEGER default 0 not null,
req_type TEXT not null,
req_id INTEGER,
req_level INTEGER,
req_optokey TEXT,
note TEXT,
check (negate IN (0, 1)),
check (owner_kind IN (
'TRAIT', 'SF', 'TALENT', 'SPELL', 'LITURGY', 'PROFESSION', 'SPECIES', 'CULTURE'
)),
check (req_type IN (
'TRAIT', 'TRAIT_LEVEL_MIN',
'ATTR_MIN', 'TALENT_MIN', 'SF',
'SPECIES', 'CULTURE', 'TRADITION', 'MERKMAL',
'EXCLUSIVE_GROUP'
))
);
create index idx_requirement_owner
on requirement (owner_kind, owner_id, group_no);
create index idx_requirement_ref
on requirement (req_type, req_id);