summaryrefslogtreecommitdiffstats
path: root/migrations
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@blos.sm>2024-11-13 20:00:15 +0000
committerLibravatar cel 🌸 <cel@blos.sm>2024-11-13 20:00:15 +0000
commitb7a2265e9b29d8fa09f84f5213ef7f8ed3045ca6 (patch)
tree280a31f5887aafdaa200a2b5f4c05ff106d9e365 /migrations
downloadcritch-b7a2265e9b29d8fa09f84f5213ef7f8ed3045ca6.tar.gz
critch-b7a2265e9b29d8fa09f84f5213ef7f8ed3045ca6.tar.bz2
critch-b7a2265e9b29d8fa09f84f5213ef7f8ed3045ca6.zip
initial commit
Diffstat (limited to 'migrations')
-rw-r--r--migrations/20241113160730_critch.sql43
1 files changed, 43 insertions, 0 deletions
diff --git a/migrations/20241113160730_critch.sql b/migrations/20241113160730_critch.sql
new file mode 100644
index 0000000..7e4b19e
--- /dev/null
+++ b/migrations/20241113160730_critch.sql
@@ -0,0 +1,43 @@
+create extension if not exists "uuid-ossp";
+
+create table artists (
+ id integer primary key generated always as identity,
+ artist_name varchar(128) not null unique,
+ bio text,
+ site varchar(256)
+);
+
+create table artworks (
+ id integer primary key generated always as identity,
+ title varchar(256),
+ description text,
+ url_source varchar(256),
+ artist_id integer not null,
+ comment_number integer not null default 0,
+ foreign key (artist_id) references artists(id)
+);
+
+create table comments (
+ id integer unique not null,
+ text text not null,
+ thread_id integer not null,
+ primary key (id, thread_id),
+ foreign key (thread_id) references artworks(id)
+);
+
+create table comment_relations (
+ thread_id integer,
+ foreign key (thread_id) references artworks(id),
+ in_reply_to_id integer,
+ foreign key (in_reply_to_id) references comments(id),
+ comment_id integer,
+ foreign key (comment_id) references comments(id),
+ primary key (thread_id, in_reply_to_id, comment_id)
+);
+
+create table files (
+ id uuid primary key default gen_random_uuid(),
+ alt_text text,
+ artwork_id integer,
+ foreign key (artwork_id) references artworks(id)
+);