add sqlite migrations
we move our PostgreSQL specific migrations to a subdirectory. The SQLite migrations have been created by running `diesel` against a copy, and then fixing what's broken. In the end i reduced all modifications to a single create, since we *are* starting out fresh with SQLite. n.b.: i'm not entirely happy with the results yet, because diesel heavily modifies our `plume-models/src/schema.rs`. I'll keep fiddling until we have the same types between the two databases.
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
-- This file was automatically created by Diesel to setup helper functions
|
||||
-- and other internal bookkeeping. This file is safe to edit, any future
|
||||
-- changes will be added to existing projects as new migrations.
|
||||
|
||||
DROP FUNCTION IF EXISTS diesel_manage_updated_at(_tbl regclass);
|
||||
DROP FUNCTION IF EXISTS diesel_set_updated_at();
|
||||
@@ -0,0 +1,36 @@
|
||||
-- This file was automatically created by Diesel to setup helper functions
|
||||
-- and other internal bookkeeping. This file is safe to edit, any future
|
||||
-- changes will be added to existing projects as new migrations.
|
||||
|
||||
|
||||
|
||||
|
||||
-- Sets up a trigger for the given table to automatically set a column called
|
||||
-- `updated_at` whenever the row is modified (unless `updated_at` was included
|
||||
-- in the modified columns)
|
||||
--
|
||||
-- # Example
|
||||
--
|
||||
-- ```sql
|
||||
-- CREATE TABLE users (id SERIAL PRIMARY KEY, updated_at TIMESTAMP NOT NULL DEFAULT NOW());
|
||||
--
|
||||
-- SELECT diesel_manage_updated_at('users');
|
||||
-- ```
|
||||
CREATE OR REPLACE FUNCTION diesel_manage_updated_at(_tbl regclass) RETURNS VOID AS $$
|
||||
BEGIN
|
||||
EXECUTE format('CREATE TRIGGER set_updated_at BEFORE UPDATE ON %s
|
||||
FOR EACH ROW EXECUTE PROCEDURE diesel_set_updated_at()', _tbl);
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE OR REPLACE FUNCTION diesel_set_updated_at() RETURNS trigger AS $$
|
||||
BEGIN
|
||||
IF (
|
||||
NEW IS DISTINCT FROM OLD AND
|
||||
NEW.updated_at IS NOT DISTINCT FROM OLD.updated_at
|
||||
) THEN
|
||||
NEW.updated_at := current_timestamp;
|
||||
END IF;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE instances;
|
||||
@@ -0,0 +1,9 @@
|
||||
-- Your SQL goes here
|
||||
CREATE TABLE instances (
|
||||
id SERIAL PRIMARY KEY,
|
||||
local_domain VARCHAR NOT NULL,
|
||||
public_domain VARCHAR NOT NULL,
|
||||
name VARCHAR NOT NULL,
|
||||
local BOOLEAN NOT NULL DEFAULT 'f',
|
||||
blocked BOOLEAN NOT NULL DEFAULT 'f'
|
||||
)
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE users;
|
||||
@@ -0,0 +1,13 @@
|
||||
-- Your SQL goes here
|
||||
CREATE TABLE users (
|
||||
id SERIAL PRIMARY KEY,
|
||||
username VARCHAR NOT NULL,
|
||||
display_name VARCHAR NOT NULL DEFAULT '',
|
||||
outbox_url VARCHAR NOT NULL,
|
||||
inbox_url VARCHAR NOT NULL,
|
||||
is_admin BOOLEAN NOT NULL DEFAULT 'f',
|
||||
summary TEXT NOT NULL DEFAULT '',
|
||||
email TEXT,
|
||||
hashed_password TEXT,
|
||||
instance_id INTEGER REFERENCES instances(id) ON DELETE CASCADE NOT NULL
|
||||
);
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE blogs;
|
||||
@@ -0,0 +1,10 @@
|
||||
-- Your SQL goes here
|
||||
CREATE TABLE blogs (
|
||||
id SERIAL PRIMARY KEY,
|
||||
actor_id VARCHAR NOT NULL,
|
||||
title VARCHAR NOT NULL,
|
||||
summary TEXT NOT NULL DEFAULT '',
|
||||
outbox_url VARCHAR NOT NULL,
|
||||
inbox_url VARCHAR NOT NULL,
|
||||
instance_id INTEGER REFERENCES instances(id) ON DELETE CASCADE NOT NULL
|
||||
)
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE blog_authors;
|
||||
@@ -0,0 +1,7 @@
|
||||
-- Your SQL goes here
|
||||
CREATE TABLE blog_authors (
|
||||
id SERIAL PRIMARY KEY,
|
||||
blog_id INTEGER REFERENCES blogs(id) ON DELETE CASCADE NOT NULL,
|
||||
author_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL,
|
||||
is_owner BOOLEAN NOT NULL DEFAULT 'f'
|
||||
)
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE posts;
|
||||
@@ -0,0 +1,10 @@
|
||||
-- Your SQL goes here
|
||||
CREATE TABLE posts (
|
||||
id SERIAL PRIMARY KEY,
|
||||
blog_id INTEGER REFERENCES blogs(id) ON DELETE CASCADE NOT NULL,
|
||||
slug VARCHAR NOT NULL,
|
||||
title VARCHAR NOT NULL,
|
||||
content TEXT NOT NULL DEFAULT '',
|
||||
published BOOLEAN NOT NULL DEFAULT 'f',
|
||||
license VARCHAR NOT NULL DEFAULT 'CC-0'
|
||||
)
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE post_authors;
|
||||
@@ -0,0 +1,6 @@
|
||||
-- Your SQL goes here
|
||||
CREATE TABLE post_authors (
|
||||
id SERIAL PRIMARY KEY,
|
||||
post_id INTEGER REFERENCES posts(id) ON DELETE CASCADE NOT NULL,
|
||||
author_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL
|
||||
)
|
||||
@@ -0,0 +1,5 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE posts DROP COLUMN creation_date;
|
||||
ALTER TABLE blogs DROP COLUMN creation_date;
|
||||
ALTER TABLE users DROP COLUMN creation_date;
|
||||
ALTER TABLE instances DROP COLUMN creation_date;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE posts ADD COLUMN creation_date TIMESTAMP NOT NULL DEFAULT now();
|
||||
ALTER TABLE blogs ADD COLUMN creation_date TIMESTAMP NOT NULL DEFAULT now();
|
||||
ALTER TABLE users ADD COLUMN creation_date TIMESTAMP NOT NULL DEFAULT now();
|
||||
ALTER TABLE instances ADD COLUMN creation_date TIMESTAMP NOT NULL DEFAULT now();
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE follows;
|
||||
@@ -0,0 +1,6 @@
|
||||
-- Your SQL goes here
|
||||
CREATE TABLE follows (
|
||||
id SERIAL PRIMARY KEY,
|
||||
follower_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL,
|
||||
following_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL
|
||||
)
|
||||
@@ -0,0 +1,3 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE blogs DROP COLUMN ap_url;
|
||||
ALTER TABLE users DROP COLUMN ap_url;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE blogs ADD COLUMN ap_url TEXT NOT NULL default '';
|
||||
ALTER TABLE users ADD COLUMN ap_url TEXT NOT NULL default '';
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE instances ADD COLUMN local_domain VARCHAR NOT NULL;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE instances DROP COLUMN local_domain;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE users DROP COLUMN private_key;
|
||||
ALTER TABLE users DROP COLUMN public_key;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE users ADD COLUMN private_key TEXT;
|
||||
ALTER TABLE users ADD COLUMN public_key TEXT NOT NULL DEFAULT '';
|
||||
@@ -0,0 +1,3 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE blogs DROP COLUMN private_key;
|
||||
ALTER TABLE blogs DROP COLUMN public_key;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE blogs ADD COLUMN private_key TEXT;
|
||||
ALTER TABLE blogs ADD COLUMN public_key TEXT NOT NULL DEFAULT '';
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE comments;
|
||||
@@ -0,0 +1,12 @@
|
||||
-- Your SQL goes here
|
||||
CREATE TABLE comments (
|
||||
id SERIAL PRIMARY KEY,
|
||||
content TEXT NOT NULL DEFAULT '',
|
||||
in_response_to_id INTEGER REFERENCES comments(id),
|
||||
post_id INTEGER REFERENCES posts(id) ON DELETE CASCADE NOT NULL,
|
||||
author_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL,
|
||||
creation_date TIMESTAMP NOT NULL DEFAULT now(),
|
||||
ap_url VARCHAR,
|
||||
sensitive BOOLEAN NOT NULL DEFAULT 'f',
|
||||
spoiler_text TEXT NOT NULL DEFAULT ''
|
||||
)
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE posts DROP COLUMN ap_url;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE posts ADD COLUMN ap_url VARCHAR NOT NULL DEFAULT '';
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE likes;
|
||||
@@ -0,0 +1,7 @@
|
||||
-- Your SQL goes here
|
||||
CREATE TABLE likes (
|
||||
id SERIAL PRIMARY KEY,
|
||||
user_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL,
|
||||
post_id INTEGER REFERENCES posts(id) ON DELETE CASCADE NOT NULL,
|
||||
creation_date TIMESTAMP NOT NULL DEFAULT now()
|
||||
)
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE likes DROP COLUMN ap_url;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE likes ADD COLUMN ap_url VARCHAR NOT NULL default '';
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE notifications;
|
||||
@@ -0,0 +1,8 @@
|
||||
-- Your SQL goes here
|
||||
CREATE TABLE notifications (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title VARCHAR NOT NULL DEFAULT '',
|
||||
content TEXT,
|
||||
link VARCHAR,
|
||||
user_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL
|
||||
)
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE users DROP COLUMN shared_inbox_url;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE users ADD COLUMN shared_inbox_url VARCHAR;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE reshares;
|
||||
@@ -0,0 +1,8 @@
|
||||
-- Your SQL goes here
|
||||
CREATE TABLE reshares (
|
||||
id SERIAL PRIMARY KEY,
|
||||
user_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL,
|
||||
post_id INTEGER REFERENCES posts(id) ON DELETE CASCADE NOT NULL,
|
||||
ap_url VARCHAR NOT NULL DEFAULT '',
|
||||
creation_date TIMESTAMP NOT NULL DEFAULT now()
|
||||
)
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE notifications DROP COLUMN creation_date;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE notifications ADD COLUMN creation_date TIMESTAMP NOT NULL DEFAULT now();
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE notifications DROP COLUMN data;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE notifications ADD COLUMN data VARCHAR;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE mentions;
|
||||
@@ -0,0 +1,7 @@
|
||||
-- Your SQL goes here
|
||||
CREATE TABLE mentions (
|
||||
id SERIAL PRIMARY KEY,
|
||||
mentioned_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL,
|
||||
post_id INTEGER REFERENCES posts(id) ON DELETE CASCADE,
|
||||
comment_id INTEGER REFERENCES comments(id) ON DELETE CASCADE
|
||||
)
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE mentions DROP COLUMN ap_url;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE mentions ADD COLUMN ap_url VARCHAR NOT NULL DEFAULT '';
|
||||
@@ -0,0 +1,8 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE notifications ADD COLUMN title VARCHAR NOT NULL;
|
||||
ALTER TABLE notifications ADD COLUMN content TEXT;
|
||||
ALTER TABLE notifications ADD COLUMN link VARCHAR;
|
||||
ALTER TABLE notifications ADD COLUMN data VARCHAR;
|
||||
|
||||
ALTER TABLE notifications DROP COLUMN kind;
|
||||
ALTER TABLE notifications DROP COLUMN object_id;
|
||||
@@ -0,0 +1,8 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE notifications DROP COLUMN title;
|
||||
ALTER TABLE notifications DROP COLUMN content;
|
||||
ALTER TABLE notifications DROP COLUMN link;
|
||||
ALTER TABLE notifications DROP COLUMN data;
|
||||
|
||||
ALTER TABLE notifications ADD COLUMN kind VARCHAR NOT NULL DEFAULT 'unknown';
|
||||
ALTER TABLE notifications ADD COLUMN object_id INTEGER NOT NULL DEFAULT 0;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE users DROP COLUMN followers_endpoint;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE users ADD COLUMN followers_endpoint VARCHAR NOT NULL DEFAULT '';
|
||||
@@ -0,0 +1,5 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE instances DROP COLUMN open_registrations;
|
||||
ALTER TABLE instances DROP COLUMN short_description;
|
||||
ALTER TABLE instances DROP COLUMN long_description;
|
||||
ALTER TABLE instances DROP COLUMN default_license;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE instances ADD COLUMN open_registrations BOOLEAN NOT NULL DEFAULT 't';
|
||||
ALTER TABLE instances ADD COLUMN short_description TEXT NOT NULL DEFAULT '';
|
||||
ALTER TABLE instances ADD COLUMN long_description TEXT NOT NULL DEFAULT '';
|
||||
ALTER TABLE instances ADD COLUMN default_license TEXT NOT NULL DEFAULT 'CC-0';
|
||||
@@ -0,0 +1,3 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE instances DROP COLUMN long_description_html;
|
||||
ALTER TABLE instances DROP COLUMN short_description_html;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE instances ADD COLUMN long_description_html VARCHAR NOT NULL DEFAULT '';
|
||||
ALTER TABLE instances ADD COLUMN short_description_html VARCHAR NOT NULL DEFAULT '';
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE medias;
|
||||
@@ -0,0 +1,10 @@
|
||||
-- Your SQL goes here
|
||||
CREATE TABLE medias (
|
||||
id SERIAL PRIMARY KEY,
|
||||
file_path TEXT NOT NULL DEFAULT '',
|
||||
alt_text TEXT NOT NULL DEFAULT '',
|
||||
is_remote BOOLEAN NOT NULL DEFAULT 'f',
|
||||
remote_url TEXT,
|
||||
sensitive BOOLEAN NOT NULL DEFAULT 'f',
|
||||
content_warning TEXT
|
||||
)
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE medias DROP COLUMN owner_id;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE medias ADD COLUMN owner_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE users DROP COLUMN avatar_id;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE users ADD COLUMN avatar_id INTEGER REFERENCES medias(id) ON DELETE CASCADE;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE users DROP COLUMN last_fetched_date;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE users ADD COLUMN last_fetched_date TIMESTAMP NOT NULL DEFAULT '2000-01-01 00:00:01';
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE follows DROP COLUMN ap_url;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE follows ADD COLUMN ap_url TEXT NOT NULL DEFAULT '';
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE posts DROP COLUMN subtitle;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE posts ADD COLUMN subtitle TEXT NOT NULL DEFAULT '';
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE tags;
|
||||
@@ -0,0 +1,7 @@
|
||||
-- Your SQL goes here
|
||||
CREATE TABLE tags (
|
||||
id SERIAL PRIMARY KEY,
|
||||
tag TEXT NOT NULL DEFAULT '',
|
||||
is_hastag BOOLEAN NOT NULL DEFAULT 'f',
|
||||
post_id INTEGER REFERENCES posts(id) ON DELETE CASCADE NOT NULL
|
||||
)
|
||||
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE posts DROP COLUMN source;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE posts ADD COLUMN source TEXT NOT NULL DEFAULT '';
|
||||
@@ -0,0 +1,7 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE users
|
||||
DROP CONSTRAINT users_avatar_id_fkey,
|
||||
ADD CONSTRAINT users_avatar_id_fkey
|
||||
FOREIGN KEY (avatar_id)
|
||||
REFERENCES medias(id)
|
||||
ON DELETE CASCADE;
|
||||
@@ -0,0 +1,7 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE users
|
||||
DROP CONSTRAINT users_avatar_id_fkey,
|
||||
ADD CONSTRAINT users_avatar_id_fkey
|
||||
FOREIGN KEY (avatar_id)
|
||||
REFERENCES medias(id)
|
||||
ON DELETE SET NULL;
|
||||
Reference in New Issue
Block a user