dismiss manual sql code, seek an ORM instead
This commit is contained in:
parent
20a6d1e114
commit
2ebf8ab55e
|
@ -7,8 +7,8 @@ edition = "2018"
|
|||
[dependencies]
|
||||
tokio = { version = "0.2", features = ["macros"] }
|
||||
warp = "0.2"
|
||||
mobc-postgres = { version = "0.5", features = ["with-chrono-0_4"] }
|
||||
mobc = "0.5"
|
||||
sqlx =
|
||||
ormx =
|
||||
serde = {version = "1.0", features = ["derive"] }
|
||||
serde_derive = "1.0"
|
||||
serde_json = "1.0"
|
||||
|
@ -24,3 +24,4 @@ chrono = { version = "0.4", features = ["serde"] }
|
|||
|
||||
# Questions: async vs sync
|
||||
# which database to use?
|
||||
# will probably substitute mobc* for sqlx and keep working with tokio.
|
||||
|
|
85
db.sql
85
db.sql
|
@ -1,85 +0,0 @@
|
|||
CREATE TABLE IF NOT EXISTS trees
|
||||
(
|
||||
id SERIAL PRIMARY KEY NOT NULL,
|
||||
lat DECIMAL(15,10) NOT NULL,
|
||||
lon DECIMAL(15,10) NOT NULL,
|
||||
species VARCHAR(255),--do not use yet, data type may change
|
||||
age INT,
|
||||
health VARCHAR(255), --do not use yet, data type may change
|
||||
created_at timestamp with time zone DEFAULT (now() at time zone 'utc'),
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS houses
|
||||
(
|
||||
id SERIAL PRIMARY KEY NOT NULL,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
built DATE NOT NULL,
|
||||
torn_down DATE,
|
||||
evicted BOOLEAN DEFAULT false NOT NULL,
|
||||
icon VARCHAR(255) NOT NULL,
|
||||
tree_id FOREIGN KEY REFERENCES trees(id)
|
||||
-- barrio_id FOREIGN KEY REFERENCES barrios(id)
|
||||
created_at timestamp with time zone DEFAULT (now() at time zone 'utc'),
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS barrios
|
||||
(
|
||||
id SERIAL PRIMARY KEY NOT NULL,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
lat DECIMAL(15,10) NOT NULL,
|
||||
lon DECIMAL(15,10) NOT NULL,
|
||||
radius DECIMAL(15,10), -- area representation may change to fit leaflet
|
||||
founded DATE NOT NULL,
|
||||
dissolved DATE,
|
||||
created_at timestamp with time zone DEFAULT (now() at time zone 'utc'),
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS photos
|
||||
(
|
||||
id SERIAL PRIMARY KEY NOT NULL,
|
||||
image_data MEDIUMBLOB NOT NULL,
|
||||
license VARCHAR(255),
|
||||
source VARCHAR(255),
|
||||
taken_at timestamp with time zone,
|
||||
created_at timestamp with time zone DEFAULT (now() at time zone 'utc'),
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS stories
|
||||
(
|
||||
id SERIAL PRIMARY KEY NOT NULL,
|
||||
author VARCHAR(255),
|
||||
colour INT, -- format 0xrrggbb
|
||||
text TEXT,
|
||||
created_at timestamp with time zone DEFAULT (now() at time zone 'utc'),
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS comments
|
||||
(
|
||||
id SERIAL PRIMARY KEY NOT NULL,
|
||||
author VARCHAR(255),
|
||||
colour INT, -- format 0xrrggbb
|
||||
text TEXT,
|
||||
parent_category INT, -- I'm looking for a better representation of a rust enum
|
||||
parent_id INT, -- ^^
|
||||
created_at timestamp with time zone DEFAULT (now() at time zone 'utc'),
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS tags
|
||||
(
|
||||
id SERIAL PRIMARY KEY NOT NULL,
|
||||
parent_category INT, -- see above
|
||||
parent_id INT, -- see above
|
||||
child_category INT, -- see above
|
||||
child_id INT, -- see above
|
||||
created_at timestamp with time zone DEFAULT (now() at time zone 'utc'),
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS users
|
||||
(
|
||||
id SERIAL PRIMARY KEY NOT NULL,
|
||||
name VARCHAR(255),
|
||||
passphrase VARCHAR(255),
|
||||
colour INT,
|
||||
role enum ('contributor','editor','admin');
|
||||
created_at timestamp with time zone DEFAULT (now() at time zone 'utc'),
|
||||
);
|
|
@ -1,7 +0,0 @@
|
|||
CREATE TABLE IF NOT EXISTS todo
|
||||
(
|
||||
id SERIAL PRIMARY KEY NOT NULL,
|
||||
name VARCHAR(255),
|
||||
created_at timestamp with time zone DEFAULT (now() at time zone 'utc'),
|
||||
checked boolean DEFAULT false
|
||||
);
|
Loading…
Reference in a new issue