Database sketch
This commit is contained in:
parent
89f8d1a23c
commit
1a5003347c
84
db.sql
84
db.sql
|
@ -1,7 +1,85 @@
|
|||
CREATE TABLE IF NOT EXISTS todo
|
||||
CREATE TABLE IF NOT EXISTS trees
|
||||
(
|
||||
id SERIAL PRIMARY KEY NOT NULL,
|
||||
name VARCHAR(255),
|
||||
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'),
|
||||
checked boolean DEFAULT false
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue