oko-server/server/sql_schema/V1_init.sql
zegkljan 8440e3b7d7
All checks were successful
continuous-integration/drone/push Build is passing
Collecting usage info, change sqlite lib.
* X-User-ID header is processed to get user ID.
* Time of last request for a user is saved into DB.
* Time of last upload and download is stored for a user.
* Added DB migration to add columns into users table to store the times and app version.
* Backward fix of datatype of the deadline column in features table.
* Switched from crawshaw.io/sqlite to zombiezen.com/go/sqlite.
  * Refactored DB handling.
  * Used migration routine from zombiezen in favour of manual one.
  * Runtime DB reinit simply deletes the db file and initializes the db anew.

Fix #6
2023-06-11 18:06:52 +02:00

24 lines
646 B
SQL

CREATE TABLE users (
id integer PRIMARY KEY AUTOINCREMENT,
name text NOT NULL UNIQUE
);
INSERT INTO users(id, name) VALUES(0, 'system');
CREATE TABLE features (
id integer PRIMARY KEY AUTOINCREMENT,
owner_id integer NOT NULL REFERENCES users(id) ON DELETE CASCADE,
name text NOT NULL,
deadline integer,
properties text NOT NULL,
geom text NOT NULL
);
CREATE TABLE feature_photos (
id integer PRIMARY KEY AUTOINCREMENT,
feature_id integer NOT NULL REFERENCES features(id) ON DELETE CASCADE,
thumbnail_content_type text NOT NULL,
content_type text NOT NULL,
thumbnail_contents blob NOT NULL,
contents blob NOT NULL
);