2024-11-08 15:47:21 -05:00
|
|
|
begin transaction;
|
|
|
|
|
2024-11-08 20:31:00 -05:00
|
|
|
create table newsgroup (
|
2025-01-07 10:10:14 -05:00
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
created_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
2024-11-26 14:04:09 -05:00
|
|
|
created_by TEXT NOT NULL,
|
2024-11-08 20:31:00 -05:00
|
|
|
name TEXT NOT NULL,
|
2024-12-02 15:09:32 -05:00
|
|
|
description TEXT NOT NULL,
|
2024-12-02 17:22:56 -05:00
|
|
|
writable BOOLEAN NOT NULL DEFAULT FALSE
|
2024-11-08 20:31:00 -05:00
|
|
|
);
|
|
|
|
|
2024-11-30 16:34:22 -05:00
|
|
|
create table message (
|
2025-01-07 10:10:14 -05:00
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
created_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
2024-11-28 07:59:06 -05:00
|
|
|
message_id TEXT NOT NULL UNIQUE,
|
|
|
|
reference_ids TEXT,
|
|
|
|
sender TEXT NOT NULL,
|
|
|
|
subject TEXT NOT NULL,
|
2024-11-30 16:34:22 -05:00
|
|
|
content TEXT NOT NULL
|
2024-11-08 15:47:21 -05:00
|
|
|
);
|
|
|
|
|
2024-12-05 00:15:37 -05:00
|
|
|
create index message_created_on_idx on message (
|
|
|
|
created_on
|
|
|
|
);
|
|
|
|
|
2024-11-30 16:34:22 -05:00
|
|
|
create table newsgroup_message (
|
|
|
|
newsgroup_id INTEGER NOT NULL,
|
2025-01-07 10:10:14 -05:00
|
|
|
message_id INTEGER NOT NULL,
|
2024-11-30 16:34:22 -05:00
|
|
|
|
|
|
|
FOREIGN KEY(newsgroup_id) REFERENCES newsgroup(id),
|
|
|
|
FOREIGN KEY(message_id) REFERENCES message(id)
|
2024-11-25 15:52:36 -05:00
|
|
|
);
|
|
|
|
|
2024-11-30 16:34:22 -05:00
|
|
|
create unique index newsgroup_message_newsgroup_id_idx on newsgroup_message (
|
|
|
|
newsgroup_id, message_id
|
2024-11-25 17:16:34 -05:00
|
|
|
);
|
|
|
|
|
2024-11-29 19:57:06 -05:00
|
|
|
create table server_permission (
|
2025-01-07 10:10:14 -05:00
|
|
|
id SERIAL PRIMARY KEY,
|
2024-11-29 19:57:06 -05:00
|
|
|
name TEXT NOT NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
insert into server_permission values
|
|
|
|
(1, 'READ'),
|
|
|
|
(2, 'POST'),
|
2024-12-06 21:55:33 -05:00
|
|
|
(3, 'ADMIN');
|
2024-11-29 19:57:06 -05:00
|
|
|
|
|
|
|
create table server_user (
|
2025-01-07 10:10:14 -05:00
|
|
|
id SERIAL PRIMARY KEY,
|
2024-11-29 19:57:06 -05:00
|
|
|
active BOOLEAN NOT NULL DEFAULT TRUE,
|
|
|
|
username TEXT NOT NULL,
|
|
|
|
password TEXT,
|
|
|
|
fullname TEXT,
|
|
|
|
mail TEXT NOT NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
create table server_user_permission (
|
|
|
|
permission_id INTEGER NOT NULL,
|
|
|
|
user_id INTEGER NOT NULL,
|
|
|
|
|
|
|
|
UNIQUE(permission_id, user_id),
|
|
|
|
FOREIGN KEY(permission_id) REFERENCES server_permission(id),
|
|
|
|
FOREIGN KEY(user_id) REFERENCES server_user(id)
|
|
|
|
);
|
|
|
|
|
2024-11-08 15:47:21 -05:00
|
|
|
commit;
|