1
0
Fork 0
forked from 2sys/phonograph
phonograph/phono-models/migrations/20260119172658_remove_forms.down.sql
2026-01-19 17:31:59 +00:00

34 lines
1.4 KiB
SQL

create table if not exists form_transitions (
id uuid not null primary key default uuidv7(),
source_id uuid not null references portals(id) on delete cascade,
dest_id uuid not null references portals(id) on delete restrict,
condition jsonb not null default 'null'
);
create index on form_transitions (source_id);
create table if not exists field_form_prompts (
id uuid not null primary key default uuidv7(),
field_id uuid not null references fields(id) on delete cascade,
language text not null,
content text not null default '',
unique (field_id, language)
);
create index on field_form_prompts (field_id);
create table if not exists form_sessions (
id uuid not null primary key default uuidv7(),
user_id uuid references users(id) on delete cascade
);
create table if not exists form_touch_points (
id uuid not null primary key default uuidv7(),
-- `on delete restrict` errs on the side of conservatism, but is not known
-- to be crucial.
form_session_id uuid not null references form_sessions(id) on delete restrict,
-- `on delete restrict` errs on the side of conservatism, but is not known
-- to be crucial.
portal_id uuid not null references portals(id) on delete restrict,
-- Points to a row in the portal's backing table, so foreign key constraints
-- do not apply here.
row_id uuid not null
);