wip: currently rewriting the project as a full stack application tangled.org/kacaii.dev/sigo
gleam
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

:art: define the primary key at the end of the table

Kacaii 4d9ec135 61f7a9ea

+18 -12
+18 -12
priv/sql/create/tables.sql
··· 60 60 -- 󰓶 TABLES ------------------------------------------------------------------- 61 61 62 62 create table if not exists public.user_account ( 63 - id uuid primary key default uuidv7(), 63 + id uuid default uuidv7(), 64 64 user_role user_role_enum not null, 65 65 full_name text not null, 66 66 password_hash text not null, ··· 69 69 email text not null unique, 70 70 is_active boolean not null default true, 71 71 created_at timestamp not null default current_timestamp, 72 - updated_at timestamp not null default current_timestamp 72 + updated_at timestamp not null default current_timestamp, 73 + primary key (id) 73 74 ); 74 75 75 76 create index if not exists idx_user_registration ··· 77 78 78 79 79 80 create table if not exists public.user_notification_preference ( 80 - id uuid primary key default uuidv7(), 81 + id uuid default uuidv7(), 81 82 user_id uuid not null references public.user_account (id) 82 83 on update cascade on delete cascade, 83 84 notification_type notification_type_enum not null, 84 85 enabled boolean not null default false, 85 86 created_at timestamp not null default current_timestamp, 86 87 updated_at timestamp not null default current_timestamp, 87 - unique (user_id, notification_type) 88 + unique (user_id, notification_type), 89 + primary key (id) 88 90 ); 89 91 90 92 91 93 create table if not exists public.brigade ( 92 - id uuid primary key default uuidv7(), 94 + id uuid default uuidv7(), 93 95 leader_id uuid not null references public.user_account (id) 94 96 on update cascade on delete cascade, 95 97 vehicle_code text not null, ··· 97 99 description text default null, 98 100 is_active boolean not null default false, 99 101 created_at timestamp not null default current_timestamp, 100 - updated_at timestamp not null default current_timestamp 102 + updated_at timestamp not null default current_timestamp, 103 + primary key (id) 101 104 ); 102 105 103 106 create index if not exists idx_brigade_leader_id ··· 105 108 106 109 107 110 create table if not exists public.brigade_membership ( 108 - id uuid primary key default uuidv7(), 111 + id uuid default uuidv7(), 109 112 brigade_id uuid not null references public.brigade (id) 110 113 on update cascade on delete cascade, 111 114 user_id uuid not null references public.user_account (id) 112 115 on update cascade on delete cascade, 113 - unique (user_id, brigade_id) 116 + unique (user_id, brigade_id), 117 + primary key (id) 114 118 ); 115 119 116 120 create index if not exists idx_brigade_membership_user_id ··· 121 125 122 126 123 127 create table if not exists public.occurrence ( 124 - id uuid primary key default uuidv7(), 128 + id uuid default uuidv7(), 125 129 applicant_id uuid not null references public.user_account (id) 126 130 on update cascade on delete cascade, 127 131 occurrence_category occurrence_category_enum not null, ··· 133 137 created_at timestamp not null default current_timestamp, 134 138 arrived_at timestamp default null, 135 139 updated_at timestamp not null default current_timestamp, 136 - resolved_at timestamp default null 140 + resolved_at timestamp default null, 141 + primary key (id) 137 142 ); 138 143 139 144 create index if not exists idx_occurrence_applicant_id ··· 144 149 145 150 146 151 create table if not exists public.occurrence_brigade ( 147 - id uuid primary key default uuidv7(), 152 + id uuid default uuidv7(), 148 153 occurrence_id uuid not null references public.occurrence (id) 149 154 on update cascade on delete cascade, 150 155 brigade_id uuid not null references public.brigade (id) 151 156 on update cascade on delete cascade, 152 - unique (occurrence_id, brigade_id) 157 + unique (occurrence_id, brigade_id), 158 + primary key (id) 153 159 ); 154 160 155 161 create index if not exists idx_occurrence_brigade_occurrence_id