clean db
This commit is contained in:
@ -26,37 +26,30 @@ CREATE TABLE IF NOT EXISTS "trip_details" (
|
||||
"allow_guests" boolean NOT NULL default false,
|
||||
"notes" TEXT,
|
||||
"always_show" boolean NOT NULL default false,
|
||||
"trip_type_id" INTEGER,
|
||||
FOREIGN KEY(trip_type_id) REFERENCES trip_type(id)
|
||||
"trip_type_id" INTEGER REFERENCES trip_type(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "planned_event" (
|
||||
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"name" text NOT NULL,
|
||||
"planned_amount_cox" INTEGER unsigned NOT NULL,
|
||||
"trip_details_id" INTEGER NOT NULL,
|
||||
"trip_details_id" INTEGER NOT NULL REFERENCES TRIP_details(id) ON DELETE CASCADE,
|
||||
"created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY(trip_details_id) REFERENCES trip_details(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "trip" (
|
||||
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"cox_id" INTEGER NOT NULL,
|
||||
"trip_details_id" INTEGER,
|
||||
"planned_event_id" INTEGER,
|
||||
"cox_id" INTEGER NOT NULL REFERENCES user(id),
|
||||
"trip_details_id" INTEGER REFERENCES trip_details(id) ON DELETE CASCADE,
|
||||
"planned_event_id" INTEGER REFERENCES planned_event(id) ON DELETE CASCADE,
|
||||
"created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY(cox_id) REFERENCES user(id),
|
||||
FOREIGN KEY(trip_details_id) REFERENCES trip_details(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY(planned_event_id) REFERENCES planned_event(id) ON DELETE CASCADE,
|
||||
CONSTRAINT unq UNIQUE (cox_id, planned_event_id) -- allow cox to participate only once for each planned event
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "user_trip" (
|
||||
"user_id" INTEGER NOT NULL,
|
||||
"trip_details_id" INTEGER NOT NULL,
|
||||
"user_id" INTEGER NOT NULL REFERENCES user(id),
|
||||
"trip_details_id" INTEGER NOT NULL REFERENCES trip_details(id),
|
||||
"created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY(user_id) REFERENCES user(id),
|
||||
FOREIGN KEY(trip_details_id) REFERENCES trip_details(id),
|
||||
CONSTRAINT unq UNIQUE (user_id, trip_details_id) -- allow user to participate only once for each trip
|
||||
);
|
||||
|
||||
@ -103,9 +96,9 @@ CREATE TABLE IF NOT EXISTS "logbook" (
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "rower" (
|
||||
"logbook_id" INTEGER NOT NULL REFERENCES logbook(id),
|
||||
"logbook_id" INTEGER NOT NULL REFERENCES logbook(id) ON DELETE CASCADE,
|
||||
"rower_id" INTEGER NOT NULL REFERENCES user(id),
|
||||
CONSTRAINT unq UNIQUE (logbook_id, rower_id)
|
||||
CONSTRAINT unq UNIQUE (logbook_id, rower_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "boat_damage" (
|
||||
|
Reference in New Issue
Block a user