create db tables for logbook
This commit is contained in:
@ -65,3 +65,57 @@ CREATE TABLE IF NOT EXISTS "log" (
|
||||
"created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "location" (
|
||||
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"name" text NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "boat" (
|
||||
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"name" text NOT NULL UNIQUE,
|
||||
"amount_seats" integer NOT NULL,
|
||||
"location_id" INTEGER NOT NULL REFERENCES location(id),
|
||||
"owner" INTEGER REFERENCES user(id), -- null: club is owner
|
||||
"year_built" INTEGER,
|
||||
"boatbuilder" TEXT,
|
||||
"default_shipmaster_only_steering" boolean default false not null,
|
||||
"skull" boolean default true NOT NULL, -- false => riemen
|
||||
"external" boolean default false NOT NULL -- false => owned by different club
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "logbook_type" (
|
||||
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"name" text NOT NULL -- e.g. 'Wanderfahrt', 'Regatta'
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "logbook" (
|
||||
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"boat_id" INTEGER NOT NULL REFERENCES boat(id),
|
||||
"shipmaster" INTEGER NOT NULL REFERENCES user(id), -- null: club is owner
|
||||
"shipmaster_only_steering" boolean not null,
|
||||
"departure" text not null,
|
||||
"arrival" text, -- None -> ship is on water
|
||||
"destination" text,
|
||||
"distance_in_km" integer,
|
||||
"comments" text,
|
||||
"type" INTEGER REFERENCES logbook_type(id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "rower" (
|
||||
"logbook_id" INTEGER NOT NULL REFERENCES logbook(id),
|
||||
"rower_id" INTEGER NOT NULL REFERENCES user(id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "boat_damage" (
|
||||
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"boat_id" INTEGER NOT NULL REFERENCES boat(id),
|
||||
"desc" text not null,
|
||||
"user_id_created" INTEGER NOT NULL REFERENCES user(id),
|
||||
"created_at" text not null,
|
||||
"user_id_fixed" INTEGER REFERENCES user(id), -- none: not fixed yet
|
||||
"fixed_at" text,
|
||||
"user_id_verified" INTEGER REFERENCES user(id),
|
||||
"verified_at" text,
|
||||
"lock_boat" boolean not null default false -- if true: noone can use the boat
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user