Add database minimal files
parent
ea66c99e6c
commit
db797e2c34
|
@ -2,4 +2,6 @@
|
|||
|
||||
Cargo.lock
|
||||
|
||||
.env
|
||||
.env
|
||||
|
||||
database.sqlite
|
|
@ -0,0 +1,9 @@
|
|||
# For documentation on how to configure this file,
|
||||
# see https://diesel.rs/guides/configuring-diesel-cli
|
||||
|
||||
[print_schema]
|
||||
file = "src/schema.rs"
|
||||
custom_type_derives = ["diesel::query_builder::QueryId"]
|
||||
|
||||
[migrations_directory]
|
||||
dir = "migrations"
|
|
@ -0,0 +1,2 @@
|
|||
DROP TABLE image;
|
||||
DROP TABLE post;
|
|
@ -0,0 +1,13 @@
|
|||
CREATE TABLE post (
|
||||
id BIGINT PRIMARY KEY NOT NULL,
|
||||
description TEXT NOT NULL,
|
||||
posted_date DATETIME NOT NULL,
|
||||
crawled_date DATETIME NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE image (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
post_id BIGINT NOT NULL,
|
||||
url TEXT NOT NULL,
|
||||
FOREIGN KEY (post_id) REFERENCES post(id)
|
||||
);
|
|
@ -0,0 +1,3 @@
|
|||
pub mod controllers;
|
||||
pub mod models;
|
||||
pub mod schema;
|
|
@ -1,3 +0,0 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
// @generated automatically by Diesel CLI.
|
||||
|
||||
diesel::table! {
|
||||
image (id) {
|
||||
id -> Integer,
|
||||
post_id -> BigInt,
|
||||
url -> Text,
|
||||
}
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
post (id) {
|
||||
id -> BigInt,
|
||||
description -> Text,
|
||||
posted_date -> Timestamp,
|
||||
crawled_date -> Timestamp,
|
||||
}
|
||||
}
|
||||
|
||||
diesel::joinable!(image -> post (post_id));
|
||||
|
||||
diesel::allow_tables_to_appear_in_same_query!(
|
||||
image,
|
||||
post,
|
||||
);
|
Loading…
Reference in New Issue