summaryrefslogtreecommitdiffstats
path: root/migrations
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@blos.sm>2023-12-13 06:50:44 +0000
committerLibravatar cel 🌸 <cel@blos.sm>2023-12-13 06:50:44 +0000
commita971d8c2dc519b1db805c72cf3395c188a98dff4 (patch)
tree98e7db2d690b778b605cf8027cd14ad1eae1f053 /migrations
parenta587459a1817c0fc57b46df3f9c69567e1e775b7 (diff)
downloadpinussy-a971d8c2dc519b1db805c72cf3395c188a98dff4.tar.gz
pinussy-a971d8c2dc519b1db805c72cf3395c188a98dff4.tar.bz2
pinussy-a971d8c2dc519b1db805c72cf3395c188a98dff4.zip
switch to uuids
Diffstat (limited to 'migrations')
-rw-r--r--migrations/20231003193749_pinussy.sql43
1 files changed, 22 insertions, 21 deletions
diff --git a/migrations/20231003193749_pinussy.sql b/migrations/20231003193749_pinussy.sql
index cba545e..4ac7474 100644
--- a/migrations/20231003193749_pinussy.sql
+++ b/migrations/20231003193749_pinussy.sql
@@ -1,8 +1,9 @@
create type privacy as enum ('private', 'unlisted', 'public');
create type file_type as enum ('image', 'video', 'audio', 'text', 'document', 'site', 'other');
+create extension if not exists "uuid-ossp";
create table users (
- id integer primary key generated always as identity,
+ id uuid primary key default gen_random_uuid(),
username varchar(32) not null,
unique(username),
password varchar(128) not null,
@@ -13,15 +14,15 @@ create table users (
admin boolean not null default true
);
-create table sessions (
- id varchar(128) primary key,
- expires timestamp with time zone,
- user_id integer not null,
- foreign key (user_id) references users(id)
-);
+-- create table sessions (
+-- id varchar(128) primary key,
+-- expires timestamp with time zone,
+-- user_id integer not null,
+-- foreign key (user_id) references users(id)
+-- );
create table boards (
- id integer primary key generated always as identity,
+ id uuid primary key default gen_random_uuid(),
idname varchar(256),
name varchar(256),
description text,
@@ -29,15 +30,15 @@ create table boards (
);
create table board_ownership (
- board_id integer not null,
- user_id integer not null,
+ board_id uuid not null,
+ user_id uuid not null,
foreign key (board_id) references boards(id),
foreign key (user_id) references users(id),
primary key (board_id, user_id)
);
create table pins (
- id integer primary key generated always as identity,
+ id uuid primary key default gen_random_uuid(),
idname varchar(256),
subject varchar(256),
notes text,
@@ -45,23 +46,23 @@ create table pins (
);
create table pin_ownership (
- pin_id integer not null,
- user_id integer not null,
+ pin_id uuid not null,
+ user_id uuid not null,
foreign key (pin_id) references pins(id),
foreign key (user_id) references users(id),
primary key (pin_id, user_id)
);
create table pins_boards (
- pin_id integer not null,
- board_id integer not null,
+ pin_id uuid not null,
+ board_id uuid not null,
foreign key (pin_id) references pins(id),
foreign key (board_id) references boards(id),
primary key (pin_id, board_id)
);
create table sources (
- id integer primary key generated always as identity,
+ id uuid primary key default gen_random_uuid(),
idname varchar(256),
title varchar(256),
author varchar(256),
@@ -72,22 +73,22 @@ create table sources (
);
create table pin_sources (
- source_id integer not null,
- pin_id integer not null,
+ source_id uuid not null,
+ pin_id uuid not null,
foreign key (source_id) references sources(id),
foreign key (pin_id) references pins(id),
primary key (source_id, pin_id)
);
create table files (
- id integer primary key generated always as identity,
+ id uuid primary key default gen_random_uuid(),
idname varchar(256),
thumbnail varchar(256),
path varchar(256) not null,
title varchar(256),
type file_type,
alt_text text,
- pin_id integer not null,
+ pin_id uuid not null,
foreign key (pin_id) references pins(id)
);
@@ -97,7 +98,7 @@ create table tags (
create table tags_pins (
tag varchar(128) not null,
- pin_id integer not null,
+ pin_id uuid not null,
foreign key (tag) references tags(tag),
foreign key (pin_id) references pins(id),
primary key (tag, pin_id)