From b28bef20a743cd3547fe57d5f607d1d14b81ea9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Gali=C4=87?= Date: Sun, 16 Sep 2018 16:22:18 +0200 Subject: [PATCH] align types between sqlite & postgres use DATETIME for SQLite's time type. This way, Diesel picks up on what it's supposed to be. --- .gitignore | 2 ++ .../2018-04-22-093322_create_instances/up.sql | 2 +- .../sqlite/2018-04-22-151330_create_user/up.sql | 2 +- .../sqlite/2018-04-23-101717_create_blogs/up.sql | 2 +- .../sqlite/2018-04-23-132822_create_posts/up.sql | 2 +- .../2018-05-09-192013_create_comments/up.sql | 2 +- .../sqlite/2018-05-10-154336_create_likes/up.sql | 2 +- .../up.sql | 2 +- .../2018-05-19-091428_create_reshares/up.sql | 2 +- plume-models/src/schema.rs | 16 ++++++++-------- 10 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 73543a98..b066582b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ Rocket.toml media docker-compose.yml *.db +*.sqlite +*.sqlite3 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 095f2b6c..83702466 100644 --- a/migrations/sqlite/2018-04-22-093322_create_instances/up.sql +++ b/migrations/sqlite/2018-04-22-093322_create_instances/up.sql @@ -5,7 +5,7 @@ CREATE TABLE instances ( name VARCHAR NOT NULL, local BOOLEAN NOT NULL DEFAULT 'f', blocked BOOLEAN NOT NULL DEFAULT 'f', - creation_date INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP, + 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 '', 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 c26055d6..4d088db3 100644 --- a/migrations/sqlite/2018-04-22-151330_create_user/up.sql +++ b/migrations/sqlite/2018-04-22-151330_create_user/up.sql @@ -11,7 +11,7 @@ CREATE TABLE users ( email TEXT, hashed_password TEXT, instance_id INTEGER REFERENCES instances(id) ON DELETE CASCADE NOT NULL, - creation_date INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP, + creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ap_url TEXT NOT NULL default '', private_key TEXT, public_key TEXT NOT NULL DEFAULT '', 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 734d22de..caa99876 100644 --- a/migrations/sqlite/2018-04-23-101717_create_blogs/up.sql +++ b/migrations/sqlite/2018-04-23-101717_create_blogs/up.sql @@ -7,7 +7,7 @@ CREATE TABLE blogs ( 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, + creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ap_url text not null default '', private_key TEXT, public_key TEXT NOT NULL DEFAULT '' 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 88050a19..7b2aa072 100644 --- a/migrations/sqlite/2018-04-23-132822_create_posts/up.sql +++ b/migrations/sqlite/2018-04-23-132822_create_posts/up.sql @@ -7,7 +7,7 @@ CREATE TABLE posts ( 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, + creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ap_url VARCHAR NOT NULL DEFAULT '', subtitle TEXT NOT NULL DEFAULT '', source 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 aec4ce1b..029a6004 100644 --- a/migrations/sqlite/2018-05-09-192013_create_comments/up.sql +++ b/migrations/sqlite/2018-05-09-192013_create_comments/up.sql @@ -5,7 +5,7 @@ CREATE TABLE comments ( 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, + creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ap_url VARCHAR, sensitive BOOLEAN NOT NULL DEFAULT 'f', spoiler_text TEXT NOT NULL DEFAULT '' 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 11b09d6a..1026af1d 100644 --- a/migrations/sqlite/2018-05-10-154336_create_likes/up.sql +++ b/migrations/sqlite/2018-05-10-154336_create_likes/up.sql @@ -4,5 +4,5 @@ CREATE TABLE likes ( 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 + creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ) 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 0266e416..06f2cdfa 100644 --- a/migrations/sqlite/2018-05-13-122311_create_notifications/up.sql +++ b/migrations/sqlite/2018-05-13-122311_create_notifications/up.sql @@ -2,7 +2,7 @@ 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, + creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, kind VARCHAR NOT NULL DEFAULT 'unknown', object_id INTEGER NOT NULL DEFAULT 0 ) 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 9435b7d0..e571ad8c 100644 --- a/migrations/sqlite/2018-05-19-091428_create_reshares/up.sql +++ b/migrations/sqlite/2018-05-19-091428_create_reshares/up.sql @@ -4,5 +4,5 @@ CREATE TABLE reshares ( 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 + creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ) diff --git a/plume-models/src/schema.rs b/plume-models/src/schema.rs index d80f9c99..e7e6f3d1 100644 --- a/plume-models/src/schema.rs +++ b/plume-models/src/schema.rs @@ -16,7 +16,7 @@ table! { outbox_url -> Text, inbox_url -> Text, instance_id -> Integer, - creation_date -> Integer, + creation_date -> Timestamp, ap_url -> Text, private_key -> Nullable, public_key -> Text, @@ -30,7 +30,7 @@ table! { in_response_to_id -> Nullable, post_id -> Integer, author_id -> Integer, - creation_date -> Integer, + creation_date -> Timestamp, ap_url -> Nullable, sensitive -> Bool, spoiler_text -> Text, @@ -53,7 +53,7 @@ table! { name -> Text, local -> Bool, blocked -> Bool, - creation_date -> Integer, + creation_date -> Timestamp, open_registrations -> Bool, short_description -> Text, long_description -> Text, @@ -69,7 +69,7 @@ table! { user_id -> Integer, post_id -> Integer, ap_url -> Text, - creation_date -> Integer, + creation_date -> Timestamp, } } @@ -100,7 +100,7 @@ table! { notifications (id) { id -> Nullable, user_id -> Integer, - creation_date -> Integer, + creation_date -> Timestamp, kind -> Text, object_id -> Integer, } @@ -123,7 +123,7 @@ table! { content -> Text, published -> Bool, license -> Text, - creation_date -> Integer, + creation_date -> Timestamp, ap_url -> Text, subtitle -> Text, source -> Text, @@ -136,7 +136,7 @@ table! { user_id -> Integer, post_id -> Integer, ap_url -> Text, - creation_date -> Integer, + creation_date -> Timestamp, } } @@ -161,7 +161,7 @@ table! { email -> Nullable, hashed_password -> Nullable, instance_id -> Integer, - creation_date -> Integer, + creation_date -> Timestamp, ap_url -> Text, private_key -> Nullable, public_key -> Text,