Merge pull request #226 from igalic/feat/sqlite
Add SQLite as supported database
This commit is contained in:
commit
b464671cf0
3
.gitignore
vendored
3
.gitignore
vendored
@ -9,3 +9,6 @@ po/*.po~
|
|||||||
Rocket.toml
|
Rocket.toml
|
||||||
media
|
media
|
||||||
docker-compose.yml
|
docker-compose.yml
|
||||||
|
*.db
|
||||||
|
*.sqlite
|
||||||
|
*.sqlite3
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
language: rust
|
language: rust
|
||||||
|
env:
|
||||||
|
matrix:
|
||||||
|
- MIGRATION_DIR=migrations/postgres FEATURES=postgres DATABASE_URL=postgres://postgres@localhost/plume
|
||||||
|
- MIGRATION_DIR=migrations/sqlite FEATURES=sqlite DATABASE_URL=plume.sqlite3
|
||||||
rust:
|
rust:
|
||||||
- nightly
|
- nightly
|
||||||
cache: cargo
|
cache: cargo
|
||||||
|
script:
|
||||||
|
- cargo build --no-default-features --features="${FEATURES}"
|
||||||
|
11
Cargo.lock
generated
11
Cargo.lock
generated
@ -475,6 +475,7 @@ dependencies = [
|
|||||||
"byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"diesel_derives 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"diesel_derives 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"libsqlite3-sys 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pq-sys 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pq-sys 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"r2d2 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"r2d2 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
@ -1001,6 +1002,15 @@ dependencies = [
|
|||||||
"crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libsqlite3-sys"
|
||||||
|
version = "0.9.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "locale_config"
|
name = "locale_config"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
@ -2882,6 +2892,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
"checksum lazycell 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d33a48d0365c96081958cc663eef834975cb1e8d8bea3378513fc72bdbf11e50"
|
"checksum lazycell 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d33a48d0365c96081958cc663eef834975cb1e8d8bea3378513fc72bdbf11e50"
|
||||||
"checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d"
|
"checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d"
|
||||||
"checksum libflate 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "7d4b4c7aff5bac19b956f693d0ea0eade8066deb092186ae954fa6ba14daab98"
|
"checksum libflate 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "7d4b4c7aff5bac19b956f693d0ea0eade8066deb092186ae954fa6ba14daab98"
|
||||||
|
"checksum libsqlite3-sys 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d3711dfd91a1081d2458ad2d06ea30a8755256e74038be2ad927d94e1c955ca8"
|
||||||
"checksum locale_config 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "14fbee0e39bc2dd6a2427c4fdea66e9826cc1fd09b0a0b7550359f5f6efe1dab"
|
"checksum locale_config 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "14fbee0e39bc2dd6a2427c4fdea66e9826cc1fd09b0a0b7550359f5f6efe1dab"
|
||||||
"checksum lock_api 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "949826a5ccf18c1b3a7c3d57692778d21768b79e46eb9dd07bfc4c2160036c54"
|
"checksum lock_api 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "949826a5ccf18c1b3a7c3d57692778d21768b79e46eb9dd07bfc4c2160036c54"
|
||||||
"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
|
"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
|
||||||
|
@ -29,7 +29,7 @@ features = ["serde"]
|
|||||||
version = "0.4"
|
version = "0.4"
|
||||||
|
|
||||||
[dependencies.diesel]
|
[dependencies.diesel]
|
||||||
features = ["postgres", "r2d2", "chrono"]
|
features = ["postgres", "sqlite", "r2d2", "chrono"]
|
||||||
version = "*"
|
version = "*"
|
||||||
|
|
||||||
[dependencies.plume-api]
|
[dependencies.plume-api]
|
||||||
@ -62,5 +62,10 @@ rev = "2805ce5dbae4a6441208484426440885a5640a6a"
|
|||||||
git = "https://github.com/BaptisteGelez/rocket_i18n"
|
git = "https://github.com/BaptisteGelez/rocket_i18n"
|
||||||
rev = "75a3bfd7b847324c078a355a7f101f8241a9f59b"
|
rev = "75a3bfd7b847324c078a355a7f101f8241a9f59b"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["postgres"]
|
||||||
|
postgres = ["plume-models/postgres"]
|
||||||
|
sqlite = ["plume-models/sqlite"]
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["plume-api", "plume-models", "plume-common"]
|
members = ["plume-api", "plume-models", "plume-common"]
|
||||||
|
5
diesel.toml
Normal file
5
diesel.toml
Normal 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"
|
@ -0,0 +1,2 @@
|
|||||||
|
-- This file should undo anything in `up.sql`
|
||||||
|
DROP TABLE instances;
|
15
migrations/sqlite/2018-04-22-093322_create_instances/up.sql
Normal file
15
migrations/sqlite/2018-04-22-093322_create_instances/up.sql
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
-- Your SQL goes here
|
||||||
|
CREATE TABLE instances (
|
||||||
|
id INTEGER NOT NULL 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 DATETIME 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 ''
|
||||||
|
)
|
2
migrations/sqlite/2018-04-22-151330_create_user/down.sql
Normal file
2
migrations/sqlite/2018-04-22-151330_create_user/down.sql
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
-- This file should undo anything in `up.sql`
|
||||||
|
DROP TABLE users;
|
23
migrations/sqlite/2018-04-22-151330_create_user/up.sql
Normal file
23
migrations/sqlite/2018-04-22-151330_create_user/up.sql
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
-- Your SQL goes here
|
||||||
|
PRAGMA foreign_keys = ON;
|
||||||
|
CREATE TABLE users (
|
||||||
|
id INTEGER NOT NULL 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 DATETIME 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
|
||||||
|
);
|
@ -0,0 +1,2 @@
|
|||||||
|
-- This file should undo anything in `up.sql`
|
||||||
|
DROP TABLE blogs;
|
14
migrations/sqlite/2018-04-23-101717_create_blogs/up.sql
Normal file
14
migrations/sqlite/2018-04-23-101717_create_blogs/up.sql
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
-- Your SQL goes here
|
||||||
|
CREATE TABLE blogs (
|
||||||
|
id INTEGER NOT NULL 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 DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
ap_url text not null default '',
|
||||||
|
private_key TEXT,
|
||||||
|
public_key TEXT NOT NULL DEFAULT ''
|
||||||
|
)
|
@ -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 INTEGER NOT NULL 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'
|
||||||
|
)
|
@ -0,0 +1,2 @@
|
|||||||
|
-- This file should undo anything in `up.sql`
|
||||||
|
DROP TABLE posts;
|
14
migrations/sqlite/2018-04-23-132822_create_posts/up.sql
Normal file
14
migrations/sqlite/2018-04-23-132822_create_posts/up.sql
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
-- Your SQL goes here
|
||||||
|
CREATE TABLE posts (
|
||||||
|
id INTEGER NOT NULL 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 DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
ap_url VARCHAR NOT NULL DEFAULT '',
|
||||||
|
subtitle TEXT NOT NULL DEFAULT '',
|
||||||
|
source TEXT NOT NULL DEFAULT ''
|
||||||
|
)
|
@ -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 INTEGER NOT NULL 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
|
||||||
|
)
|
@ -0,0 +1,2 @@
|
|||||||
|
-- This file should undo anything in `up.sql`
|
||||||
|
DROP TABLE follows;
|
7
migrations/sqlite/2018-05-01-124607_create_follow/up.sql
Normal file
7
migrations/sqlite/2018-05-01-124607_create_follow/up.sql
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
-- Your SQL goes here
|
||||||
|
CREATE TABLE follows (
|
||||||
|
id INTEGER NOT NULL 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 ''
|
||||||
|
)
|
@ -0,0 +1,2 @@
|
|||||||
|
-- This file should undo anything in `up.sql`
|
||||||
|
DROP TABLE comments;
|
12
migrations/sqlite/2018-05-09-192013_create_comments/up.sql
Normal file
12
migrations/sqlite/2018-05-09-192013_create_comments/up.sql
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
-- Your SQL goes here
|
||||||
|
CREATE TABLE comments (
|
||||||
|
id INTEGER NOT NULL 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 DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
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`
|
||||||
|
DROP TABLE likes;
|
8
migrations/sqlite/2018-05-10-154336_create_likes/up.sql
Normal file
8
migrations/sqlite/2018-05-10-154336_create_likes/up.sql
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
-- Your SQL goes here
|
||||||
|
CREATE TABLE likes (
|
||||||
|
id INTEGER NOT NULL 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,
|
||||||
|
creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
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 INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||||
|
user_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL,
|
||||||
|
creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
kind VARCHAR NOT NULL DEFAULT 'unknown',
|
||||||
|
object_id INTEGER NOT NULL DEFAULT 0
|
||||||
|
)
|
@ -0,0 +1,2 @@
|
|||||||
|
-- This file should undo anything in `up.sql`
|
||||||
|
DROP TABLE reshares;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user