From 88456faf84f885f031fdc528ea63370147d976c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Gali=C4=87?= Date: Mon, 17 Sep 2018 11:08:58 +0200 Subject: [PATCH] align types between sqlite & postgres this one's achieved by adding "NOT NULL" at the *correct* position in SQLite's create tables. --- .../2018-04-22-093322_create_instances/up.sql | 2 +- .../2018-04-22-151330_create_user/up.sql | 2 +- .../2018-04-23-101717_create_blogs/up.sql | 2 +- .../up.sql | 2 +- .../2018-04-23-132822_create_posts/up.sql | 2 +- .../up.sql | 2 +- .../2018-05-01-124607_create_follow/up.sql | 2 +- .../2018-05-09-192013_create_comments/up.sql | 2 +- .../2018-05-10-154336_create_likes/up.sql | 2 +- .../up.sql | 2 +- .../2018-05-19-091428_create_reshares/up.sql | 2 +- .../2018-06-20-175532_create_mentions/up.sql | 2 +- .../2018-09-02-111458_create_medias/up.sql | 2 +- .../2018-09-05-174106_create_tags/up.sql | 2 +- plume-models/src/schema.rs | 28 +++++++++---------- 15 files changed, 28 insertions(+), 28 deletions(-) diff --git a/migrations/sqlite/2018-04-22-093322_create_instances/up.sql b/migrations/sqlite/2018-04-22-093322_create_instances/up.sql index 83702466..37f1ef67 100644 --- a/migrations/sqlite/2018-04-22-093322_create_instances/up.sql +++ b/migrations/sqlite/2018-04-22-093322_create_instances/up.sql @@ -1,6 +1,6 @@ -- Your SQL goes here CREATE TABLE instances ( - id INTEGER PRIMARY KEY AUTOINCREMENT, + id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, public_domain VARCHAR NOT NULL, name VARCHAR NOT NULL, local BOOLEAN NOT NULL DEFAULT 'f', diff --git a/migrations/sqlite/2018-04-22-151330_create_user/up.sql b/migrations/sqlite/2018-04-22-151330_create_user/up.sql index 4d088db3..3da556b5 100644 --- a/migrations/sqlite/2018-04-22-151330_create_user/up.sql +++ b/migrations/sqlite/2018-04-22-151330_create_user/up.sql @@ -1,7 +1,7 @@ -- Your SQL goes here PRAGMA foreign_keys = ON; CREATE TABLE users ( - id INTEGER PRIMARY KEY AUTOINCREMENT, + id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, username VARCHAR NOT NULL, display_name VARCHAR NOT NULL DEFAULT '', outbox_url VARCHAR NOT NULL, diff --git a/migrations/sqlite/2018-04-23-101717_create_blogs/up.sql b/migrations/sqlite/2018-04-23-101717_create_blogs/up.sql index caa99876..30635a5c 100644 --- a/migrations/sqlite/2018-04-23-101717_create_blogs/up.sql +++ b/migrations/sqlite/2018-04-23-101717_create_blogs/up.sql @@ -1,6 +1,6 @@ -- Your SQL goes here CREATE TABLE blogs ( - id INTEGER PRIMARY KEY AUTOINCREMENT, + id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, actor_id VARCHAR NOT NULL, title VARCHAR NOT NULL, summary TEXT NOT NULL DEFAULT '', diff --git a/migrations/sqlite/2018-04-23-111655_create_blog_authors/up.sql b/migrations/sqlite/2018-04-23-111655_create_blog_authors/up.sql index 58846c63..10144614 100644 --- a/migrations/sqlite/2018-04-23-111655_create_blog_authors/up.sql +++ b/migrations/sqlite/2018-04-23-111655_create_blog_authors/up.sql @@ -1,6 +1,6 @@ -- Your SQL goes here CREATE TABLE blog_authors ( - id INTEGER PRIMARY KEY AUTOINCREMENT, + 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' diff --git a/migrations/sqlite/2018-04-23-132822_create_posts/up.sql b/migrations/sqlite/2018-04-23-132822_create_posts/up.sql index 7b2aa072..d88337f5 100644 --- a/migrations/sqlite/2018-04-23-132822_create_posts/up.sql +++ b/migrations/sqlite/2018-04-23-132822_create_posts/up.sql @@ -1,6 +1,6 @@ -- Your SQL goes here CREATE TABLE posts ( - id INTEGER PRIMARY KEY AUTOINCREMENT, + 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, diff --git a/migrations/sqlite/2018-04-23-142746_create_post_authors/up.sql b/migrations/sqlite/2018-04-23-142746_create_post_authors/up.sql index 49991afa..214a6f3f 100644 --- a/migrations/sqlite/2018-04-23-142746_create_post_authors/up.sql +++ b/migrations/sqlite/2018-04-23-142746_create_post_authors/up.sql @@ -1,6 +1,6 @@ -- Your SQL goes here CREATE TABLE post_authors ( - id INTEGER PRIMARY KEY AUTOINCREMENT, + 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 ) diff --git a/migrations/sqlite/2018-05-01-124607_create_follow/up.sql b/migrations/sqlite/2018-05-01-124607_create_follow/up.sql index c31d2324..7eeda5aa 100644 --- a/migrations/sqlite/2018-05-01-124607_create_follow/up.sql +++ b/migrations/sqlite/2018-05-01-124607_create_follow/up.sql @@ -1,6 +1,6 @@ -- Your SQL goes here CREATE TABLE follows ( - id INTEGER PRIMARY KEY AUTOINCREMENT, + 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 '' diff --git a/migrations/sqlite/2018-05-09-192013_create_comments/up.sql b/migrations/sqlite/2018-05-09-192013_create_comments/up.sql index 029a6004..901c0699 100644 --- a/migrations/sqlite/2018-05-09-192013_create_comments/up.sql +++ b/migrations/sqlite/2018-05-09-192013_create_comments/up.sql @@ -1,6 +1,6 @@ -- Your SQL goes here CREATE TABLE comments ( - id INTEGER PRIMARY KEY AUTOINCREMENT, + 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, diff --git a/migrations/sqlite/2018-05-10-154336_create_likes/up.sql b/migrations/sqlite/2018-05-10-154336_create_likes/up.sql index 1026af1d..0309fb0a 100644 --- a/migrations/sqlite/2018-05-10-154336_create_likes/up.sql +++ b/migrations/sqlite/2018-05-10-154336_create_likes/up.sql @@ -1,6 +1,6 @@ -- Your SQL goes here CREATE TABLE likes ( - id INTEGER PRIMARY KEY AUTOINCREMENT, + 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, ap_url VARCHAR NOT NULL default '', diff --git a/migrations/sqlite/2018-05-13-122311_create_notifications/up.sql b/migrations/sqlite/2018-05-13-122311_create_notifications/up.sql index 06f2cdfa..ceb45ee8 100644 --- a/migrations/sqlite/2018-05-13-122311_create_notifications/up.sql +++ b/migrations/sqlite/2018-05-13-122311_create_notifications/up.sql @@ -1,6 +1,6 @@ -- Your SQL goes here CREATE TABLE notifications ( - id INTEGER PRIMARY KEY AUTOINCREMENT, + 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', diff --git a/migrations/sqlite/2018-05-19-091428_create_reshares/up.sql b/migrations/sqlite/2018-05-19-091428_create_reshares/up.sql index e571ad8c..cee70f74 100644 --- a/migrations/sqlite/2018-05-19-091428_create_reshares/up.sql +++ b/migrations/sqlite/2018-05-19-091428_create_reshares/up.sql @@ -1,6 +1,6 @@ -- Your SQL goes here CREATE TABLE reshares ( - id INTEGER PRIMARY KEY AUTOINCREMENT, + 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, ap_url VARCHAR NOT NULL DEFAULT '', diff --git a/migrations/sqlite/2018-06-20-175532_create_mentions/up.sql b/migrations/sqlite/2018-06-20-175532_create_mentions/up.sql index 35cc3b55..3f28aa9c 100644 --- a/migrations/sqlite/2018-06-20-175532_create_mentions/up.sql +++ b/migrations/sqlite/2018-06-20-175532_create_mentions/up.sql @@ -1,6 +1,6 @@ -- Your SQL goes here CREATE TABLE mentions ( - id INTEGER PRIMARY KEY AUTOINCREMENT, + id INTEGER NOT NULL 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, diff --git a/migrations/sqlite/2018-09-02-111458_create_medias/up.sql b/migrations/sqlite/2018-09-02-111458_create_medias/up.sql index 3f804e27..e2ac093c 100644 --- a/migrations/sqlite/2018-09-02-111458_create_medias/up.sql +++ b/migrations/sqlite/2018-09-02-111458_create_medias/up.sql @@ -1,6 +1,6 @@ -- Your SQL goes here CREATE TABLE medias ( - id INTEGER PRIMARY KEY AUTOINCREMENT, + id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, file_path TEXT NOT NULL DEFAULT '', alt_text TEXT NOT NULL DEFAULT '', is_remote BOOLEAN NOT NULL DEFAULT 'f', diff --git a/migrations/sqlite/2018-09-05-174106_create_tags/up.sql b/migrations/sqlite/2018-09-05-174106_create_tags/up.sql index 15e95beb..031b4ed2 100644 --- a/migrations/sqlite/2018-09-05-174106_create_tags/up.sql +++ b/migrations/sqlite/2018-09-05-174106_create_tags/up.sql @@ -1,6 +1,6 @@ -- Your SQL goes here CREATE TABLE tags ( - id INTEGER PRIMARY KEY AUTOINCREMENT, + id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, tag TEXT NOT NULL DEFAULT '', is_hastag BOOLEAN NOT NULL DEFAULT 'f', post_id INTEGER REFERENCES posts(id) ON DELETE CASCADE NOT NULL diff --git a/plume-models/src/schema.rs b/plume-models/src/schema.rs index e7e6f3d1..539db327 100644 --- a/plume-models/src/schema.rs +++ b/plume-models/src/schema.rs @@ -1,6 +1,6 @@ table! { blog_authors (id) { - id -> Nullable, + id -> Integer, blog_id -> Integer, author_id -> Integer, is_owner -> Bool, @@ -9,7 +9,7 @@ table! { table! { blogs (id) { - id -> Nullable, + id -> Integer, actor_id -> Text, title -> Text, summary -> Text, @@ -25,7 +25,7 @@ table! { table! { comments (id) { - id -> Nullable, + id -> Integer, content -> Text, in_response_to_id -> Nullable, post_id -> Integer, @@ -39,7 +39,7 @@ table! { table! { follows (id) { - id -> Nullable, + id -> Integer, follower_id -> Integer, following_id -> Integer, ap_url -> Text, @@ -48,7 +48,7 @@ table! { table! { instances (id) { - id -> Nullable, + id -> Integer, public_domain -> Text, name -> Text, local -> Bool, @@ -65,7 +65,7 @@ table! { table! { likes (id) { - id -> Nullable, + id -> Integer, user_id -> Integer, post_id -> Integer, ap_url -> Text, @@ -75,7 +75,7 @@ table! { table! { medias (id) { - id -> Nullable, + id -> Integer, file_path -> Text, alt_text -> Text, is_remote -> Bool, @@ -88,7 +88,7 @@ table! { table! { mentions (id) { - id -> Nullable, + id -> Integer, mentioned_id -> Integer, post_id -> Nullable, comment_id -> Nullable, @@ -98,7 +98,7 @@ table! { table! { notifications (id) { - id -> Nullable, + id -> Integer, user_id -> Integer, creation_date -> Timestamp, kind -> Text, @@ -108,7 +108,7 @@ table! { table! { post_authors (id) { - id -> Nullable, + id -> Integer, post_id -> Integer, author_id -> Integer, } @@ -116,7 +116,7 @@ table! { table! { posts (id) { - id -> Nullable, + id -> Integer, blog_id -> Integer, slug -> Text, title -> Text, @@ -132,7 +132,7 @@ table! { table! { reshares (id) { - id -> Nullable, + id -> Integer, user_id -> Integer, post_id -> Integer, ap_url -> Text, @@ -142,7 +142,7 @@ table! { table! { tags (id) { - id -> Nullable, + id -> Integer, tag -> Text, is_hastag -> Bool, post_id -> Integer, @@ -151,7 +151,7 @@ table! { table! { users (id) { - id -> Nullable, + id -> Integer, username -> Text, display_name -> Text, outbox_url -> Text,