gourami

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

commit fc34c920fd601a743c0193fbb456f02efb6e5504
parent 91b2dd2a724e387a5d21d1b65099cde64083f625
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sun, 26 Apr 2020 13:33:36 -0500

Add migration

Diffstat:
Mmigrations/2020-04-13-014917_initialize/up.sql | 22++++------------------
Amigrations/2020-04-26-181415_new/down.sql | 2++
Amigrations/2020-04-26-181415_new/up.sql | 35+++++++++++++++++++++++++++++++++++
3 files changed, 41 insertions(+), 18 deletions(-)

diff --git a/migrations/2020-04-13-014917_initialize/up.sql b/migrations/2020-04-13-014917_initialize/up.sql @@ -6,8 +6,7 @@ CREATE TABLE users ( email VARCHAR(255), bio VARCHAR(1023) default "New here!", created_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP , - password VARCHAR(255), - admin BOOLEAN default false + password VARCHAR(255) ); CREATE UNIQUE INDEX users_username_idx ON users (username); @@ -33,23 +32,10 @@ CREATE TABLE sessions ( CREATE TABLE notes ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - user_id INTEGER REFERENCES users(id), - in_reply_to INTEGER REFERENCES notes(id), + creator_id INTEGER REFERENCES users(id), + creator_username VARCHAR(255), -- TODO: better solution here. maybe a view + parent_id INTEGER, content TEXT, created_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); - -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-26-181415_new/down.sql b/migrations/2020-04-26-181415_new/down.sql @@ -0,0 +1 @@ +-- 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 @@ -0,0 +1,35 @@ +-- 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) +); +