diff --git a/migrations/2020-02-21-011449_create_items/down.sql b/migrations/2020-02-21-011449_create_items/down.sql new file mode 100644 index 0000000..296bcf2 --- /dev/null +++ b/migrations/2020-02-21-011449_create_items/down.sql @@ -0,0 +1 @@ +DROP TABLE items \ No newline at end of file diff --git a/migrations/2020-02-21-011449_create_items/up.sql b/migrations/2020-02-21-011449_create_items/up.sql new file mode 100644 index 0000000..0246dbe --- /dev/null +++ b/migrations/2020-02-21-011449_create_items/up.sql @@ -0,0 +1,13 @@ +CREATE TABLE items ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + owner INTEGER NOT NULL, + uuid VARCHAR NOT NULL, + content VARCHAR, + content_type VARCHAR NOT NULL, + enc_item_key VARCHAR, + deleted BOOLEAN NOT NULL, + created_at DATE NOT NULL, + updated_at DATE NOT NULL, + FOREIGN KEY (owner) + REFERENCES users (id) +) \ No newline at end of file diff --git a/src/schema.rs b/src/schema.rs index f148ffe..91ecf83 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -1,3 +1,17 @@ +table! { + items (id) { + id -> Integer, + owner -> Integer, + uuid -> Text, + content -> Nullable, + content_type -> Text, + enc_item_key -> Nullable, + deleted -> Bool, + created_at -> Date, + updated_at -> Date, + } +} + table! { users (id) { id -> Integer, @@ -8,3 +22,10 @@ table! { version -> Text, } } + +joinable!(items -> users (owner)); + +allow_tables_to_appear_in_same_query!( + items, + users, +);