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:
Igor Galić 2018-09-15 13:38:09 +02:00
parent e5691f7b23
commit 1f8680c4c5
Signed by untrusted user who does not match committer: igalic
GPG key ID: ACFEFF7F6A123A86
105 changed files with 251 additions and 69 deletions

1
.gitignore vendored
View file

@ -9,3 +9,4 @@ po/*.po~
Rocket.toml Rocket.toml
media media
docker-compose.yml docker-compose.yml
*.db

5
diesel.toml Normal file
View file

@ -0,0 +1,5 @@
# For documentation on how to configure this file,
# see diesel.rs/guides/configuring-diesel-cli
[print_schema]
file = "plume-models/src/schema.rs"

View file

@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
DROP TABLE instances;

View file

@ -0,0 +1,15 @@
-- Your SQL goes here
CREATE TABLE instances (
id INTEGER PRIMARY KEY AUTOINCREMENT,
public_domain VARCHAR NOT NULL,
name VARCHAR NOT NULL,
local BOOLEAN NOT NULL DEFAULT 'f',
blocked BOOLEAN NOT NULL DEFAULT 'f',
creation_date INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP,
open_registrations BOOLEAN NOT NULL DEFAULT 't',
short_description TEXT NOT NULL DEFAULT '',
long_description TEXT NOT NULL DEFAULT '',
default_license TEXT NOT NULL DEFAULT 'CC-0',
long_description_html VARCHAR NOT NULL DEFAULT '',
short_description_html VARCHAR NOT NULL DEFAULT ''
)

View file

@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
DROP TABLE users;

View file

@ -0,0 +1,23 @@
-- Your SQL goes here
PRAGMA foreign_keys = ON;
CREATE TABLE users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
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,
creation_date INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP,
ap_url TEXT NOT NULL default '',
private_key TEXT,
public_key TEXT NOT NULL DEFAULT '',
shared_inbox_url VARCHAR,
followers_endpoint VARCHAR NOT NULL DEFAULT '',
avatar_id INTEGER REFERENCES medias(id) ON DELETE CASCADE,
last_fetched_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (avatar_id) REFERENCES medias(id) ON DELETE SET NULL
);

View file

@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
DROP TABLE blogs;

View file

@ -0,0 +1,14 @@
-- Your SQL goes here
CREATE TABLE blogs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
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,
creation_date INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP,
ap_url text not null default '',
private_key TEXT,
public_key TEXT NOT NULL DEFAULT ''
)

View file

@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
DROP TABLE blog_authors;

View file

@ -0,0 +1,7 @@
-- Your SQL goes here
CREATE TABLE blog_authors (
id INTEGER PRIMARY KEY AUTOINCREMENT,
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'
)

View file

@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
DROP TABLE posts;

View file

@ -0,0 +1,14 @@
-- Your SQL goes here
CREATE TABLE posts (
id INTEGER PRIMARY KEY AUTOINCREMENT,
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',
creation_date INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP,
ap_url VARCHAR NOT NULL DEFAULT '',
subtitle TEXT NOT NULL DEFAULT '',
source TEXT NOT NULL DEFAULT ''
)

View file

@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
DROP TABLE post_authors;

View file

@ -0,0 +1,6 @@
-- Your SQL goes here
CREATE TABLE post_authors (
id INTEGER PRIMARY KEY AUTOINCREMENT,
post_id INTEGER REFERENCES posts(id) ON DELETE CASCADE NOT NULL,
author_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL
)

View file

@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
DROP TABLE follows;

View file

@ -0,0 +1,7 @@
-- Your SQL goes here
CREATE TABLE follows (
id INTEGER PRIMARY KEY AUTOINCREMENT,
follower_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL,
following_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL,
ap_url TEXT NOT NULL default ''
)

View file

@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
DROP TABLE comments;

View file

@ -0,0 +1,12 @@
-- Your SQL goes here
CREATE TABLE comments (
id INTEGER PRIMARY KEY AUTOINCREMENT,
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 INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP,
ap_url VARCHAR,
sensitive BOOLEAN NOT NULL DEFAULT 'f',
spoiler_text TEXT NOT NULL DEFAULT ''
)

View file

@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
DROP TABLE likes;

View file

@ -0,0 +1,8 @@
-- Your SQL goes here
CREATE TABLE likes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
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 INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP
)

View file

@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
DROP TABLE notifications;

View file

@ -0,0 +1,8 @@
-- Your SQL goes here
CREATE TABLE notifications (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL,
creation_date INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP,
kind VARCHAR NOT NULL DEFAULT 'unknown',
object_id INTEGER NOT NULL DEFAULT 0
)

View file

@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
DROP TABLE reshares;

View file

@ -0,0 +1,8 @@
-- Your SQL goes here
CREATE TABLE reshares (
id INTEGER PRIMARY KEY AUTOINCREMENT,
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 INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP
)

View file

@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
DROP TABLE mentions;

View file

@ -0,0 +1,8 @@
-- Your SQL goes here
CREATE TABLE mentions (
id INTEGER PRIMARY KEY AUTOINCREMENT,
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,
ap_url VARCHAR NOT NULL DEFAULT ''
)

Some files were not shown because too many files have changed in this diff Show more