gourami

[UNMAINTAINED] Activitypub server in Rust
Log | Files | Refs | README | LICENSE

commit c17ccb570b71e38f2cd8a82f79549436fb692d57
parent f0a646327fa21fb7dbb733acd81c5b51f2191894
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sat,  9 May 2020 19:36:41 -0500

Merge all migrations into one

Going to keep it like this while things are relatively unstable

Diffstat:
Mmigrations/2020-04-13-014917_initialize/down.sql | 12++++++++++--
Mmigrations/2020-04-13-014917_initialize/up.sql | 44+++++++++++++++++++++++++++++++++++++-------
Dmigrations/2020-04-26-181415_new/down.sql | 2--
Dmigrations/2020-04-26-181415_new/up.sql | 35-----------------------------------
Dmigrations/2020-04-28-222918_neighborhood/down.sql | 2--
Dmigrations/2020-04-28-222918_neighborhood/up.sql | 5-----
Dmigrations/2020-04-29-162311_ap-restructure/down.sql | 2--
Dmigrations/2020-04-29-162311_ap-restructure/up.sql | 6------
Dmigrations/2020-05-02-001130_remoteuser/down.sql | 2--
Dmigrations/2020-05-02-001130_remoteuser/up.sql | 12------------
Dmigrations/2020-05-08-203656_showemail/down.sql | 2--
Dmigrations/2020-05-08-203656_showemail/up.sql | 3---
Msrc/db/schema.rs | 2++
13 files changed, 49 insertions(+), 80 deletions(-)

diff --git a/migrations/2020-04-13-014917_initialize/down.sql b/migrations/2020-04-13-014917_initialize/down.sql @@ -1 +1,10 @@ --- This file should undo anything in `up.sql` -\ No newline at end of file +-- This file should undo anything in `up.sql` + +drop table if exists users; +drop table if exists registration_keys; +drop table if exists activities; +drop table if exists notifications; +drop table if exists notification_viewers; +drop table if exists sessions; +drop table if exists notes; +drop table if exists server_mutuals; diff --git a/migrations/2020-04-13-014917_initialize/up.sql b/migrations/2020-04-13-014917_initialize/up.sql @@ -6,9 +6,12 @@ CREATE TABLE users ( email VARCHAR(255), bio VARCHAR(1023) default "New here!", created_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP , - password VARCHAR(255) + password VARCHAR(255), + admin BOOLEAN default false, + show_email BOOLEAN default false, + remote_url VARCHAR(100) ); - +create unique index unique_remote on users(remote_url); CREATE UNIQUE INDEX users_username_idx ON users (username); CREATE UNIQUE INDEX users_email_idx ON users (email); @@ -21,6 +24,21 @@ CREATE TABLE activities ( json_text TEXT ); + +CREATE TABLE notifications ( + id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + notification_html TEXT, + server_message BOOLEAN, + created_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + +CREATE TABLE notification_viewers ( + notification_id INTEGER REFERENCES notifications(id), + user_id INTEGER REFERENCES users(id), + viewed BOOLEAN, + PRIMARY KEY (notification_id, user_id) +); + CREATE TABLE sessions ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, cookie VARCHAR NOT NULL, @@ -28,14 +46,26 @@ CREATE TABLE sessions ( created_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); --- media_attachments CREATE TABLE notes ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - creator_id INTEGER REFERENCES users(id), - creator_username VARCHAR(255), -- TODO: better solution here. maybe a view - parent_id INTEGER, + user_id INTEGER REFERENCES users(id), content TEXT, - created_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP + created_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + in_reply_to references notes(id), + neighborhood BOOLEAN, + is_remote boolean default false, + remote_url varchar(1000), + remote_creator varchar(1000), + remote_id varchar(1000) +); + +create table server_mutuals ( + id integer primary key autoincrement, + inbox_url VARCHAR(1000), + accepted boolean default false, + followed_back boolean default false, + outbox_url VARCHAR(1000) ); +create unique index unique_inbox on server_mutuals(inbox_url); diff --git a/migrations/2020-04-26-181415_new/down.sql b/migrations/2020-04-26-181415_new/down.sql @@ -1 +0,0 @@ --- This file should undo anything in `up.sql` -\ No newline at end of file diff --git a/migrations/2020-04-26-181415_new/up.sql b/migrations/2020-04-26-181415_new/up.sql @@ -1,35 +0,0 @@ --- Your SQL goes here - -CREATE TABLE notes_temp ( -id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, -user_id INTEGER REFERENCES users(id), -content TEXT, -created_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP -); -INSERT INTO notes_temp(id,user_id,content,created_time) -SELECT id,creator_id,content,created_time -FROM notes; - -drop table notes; -alter table notes_temp rename to notes; - -alter table notes -add column in_reply_to references notes(id); - -alter table users -add column admin boolean default false; - -CREATE TABLE notifications ( - id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - notification_html TEXT, - server_message BOOLEAN, - created_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP -); - -CREATE TABLE notification_viewers ( - notification_id INTEGER REFERENCES notifications(id), - user_id INTEGER REFERENCES users(id), - viewed BOOLEAN, - PRIMARY KEY (notification_id, user_id) -); - diff --git a/migrations/2020-04-28-222918_neighborhood/down.sql b/migrations/2020-04-28-222918_neighborhood/down.sql @@ -1 +0,0 @@ --- This file should undo anything in `up.sql` -\ No newline at end of file diff --git a/migrations/2020-04-28-222918_neighborhood/up.sql b/migrations/2020-04-28-222918_neighborhood/up.sql @@ -1,5 +0,0 @@ --- Your SQL goes here - -Alter table notes -add neighborhood BOOLEAN default false; - diff --git a/migrations/2020-04-29-162311_ap-restructure/down.sql b/migrations/2020-04-29-162311_ap-restructure/down.sql @@ -1 +0,0 @@ --- This file should undo anything in `up.sql` -\ No newline at end of file diff --git a/migrations/2020-04-29-162311_ap-restructure/up.sql b/migrations/2020-04-29-162311_ap-restructure/up.sql @@ -1,6 +0,0 @@ --- Your SQL goes here - -alter table notes add is_remote boolean default false; -alter table notes add remote_url varchar(1000); -- semi-arbitrary -alter table notes add remote_creator varchar(1000); -- semi-arbitrary -alter table notes add remote_id varchar(1000); -- semi-arbitrary; diff --git a/migrations/2020-05-02-001130_remoteuser/down.sql b/migrations/2020-05-02-001130_remoteuser/down.sql @@ -1 +0,0 @@ --- This file should undo anything in `up.sql` -\ No newline at end of file diff --git a/migrations/2020-05-02-001130_remoteuser/up.sql b/migrations/2020-05-02-001130_remoteuser/up.sql @@ -1,12 +0,0 @@ --- Your SQL goes here - -alter table users add remote_url VARCHAR(1000); - -create unique index uniqremote on users(remote_url); - -create table server_mutuals ( - id integer primary key autoincrement, - inbox_url VARCHAR(1000), - outbox_url VARCHAR(1000) -); - diff --git a/migrations/2020-05-08-203656_showemail/down.sql b/migrations/2020-05-08-203656_showemail/down.sql @@ -1 +0,0 @@ --- This file should undo anything in `up.sql` -\ No newline at end of file diff --git a/migrations/2020-05-08-203656_showemail/up.sql b/migrations/2020-05-08-203656_showemail/up.sql @@ -1,3 +0,0 @@ --- Your SQL goes here - -alter table users add show_email boolean default false; diff --git a/src/db/schema.rs b/src/db/schema.rs @@ -63,6 +63,8 @@ table! { server_mutuals (id) { id -> Integer, inbox_url -> Varchar, + accepted -> Bool, + followed_back -> Bool, outbox_url -> Nullable<Varchar>, } }