Skip to content

Commit 12cb88a

Browse files
committed
Update schema with topic channels and better messages.
1 parent 779f173 commit 12cb88a

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

Database/bin/create-classes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
CLASS_NAME=$1
3+
CLASS_NAME="OpenNewsWire::DB"
44

55
# Generate a random 8 character name for the docker container that holds the PSQL
66
# database.

Database/etc/schema.sql

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ CREATE TABLE person (
88
created_at timestamptz not null default current_timestamp
99
);
1010

11+
-- Settings for a given user. | Use with care, add things to the data model when you should.
12+
create TABLE person_settings (
13+
id serial PRIMARY KEY,
14+
person_id int not null references person(id),
15+
name text not null,
16+
value json not null default '{}',
17+
created_at timestamptz not null default current_timestamp,
18+
19+
-- Allow ->find_or_new_related()
20+
CONSTRAINT unq_person_id_name UNIQUE(person_id, name)
21+
);
22+
1123
CREATE TABLE auth_password (
1224
person_id int not null unique references person(id),
1325
password text not null,
@@ -19,7 +31,10 @@ CREATE TABLE auth_password (
1931
CREATE TABLE message (
2032
id serial PRIMARY KEY,
2133
author_id int not null references person(id),
34+
parent_id int references message(id),
35+
title text ,
2236
content text not null,
37+
url text ,
2338
created_at timestamptz not null default current_timestamp
2439
);
2540

@@ -31,3 +46,32 @@ CREATE TABLE message_read (
3146
PRIMARY KEY (message_id, person_id)
3247
);
3348

49+
CREATE TABLE topic_channel (
50+
id serial PRIMARY KEY,
51+
owner_id int not null references person(id),
52+
name text not null,
53+
is_enabled boolean not null default true,
54+
created_at timestamptz not null default current_timestamp
55+
);
56+
57+
-- Settings for a given channel. | Use with care, add things to the data model when you should.
58+
create TABLE topic_channel_settings (
59+
id serial PRIMARY KEY,
60+
topic_channel_id int not null references topic_channel(id),
61+
name text not null,
62+
value json not null default '{}',
63+
created_at timestamptz not null default current_timestamp,
64+
65+
-- Allow ->find_or_new_related()
66+
CONSTRAINT unq_channel_id_name UNIQUE(topic_channel_id, name)
67+
);
68+
69+
create TABLE topic_channel_message (
70+
id serial PRIMARY KEY,
71+
author_id int not null references person(id),
72+
channel_id int not null references topic_channel(id),
73+
message_id int not null references message(id),
74+
is_archived boolean not null default false,
75+
is_stickied boolean not null default false,
76+
created_at timestamptz not null default current_timestamp
77+
);

0 commit comments

Comments
 (0)