kinda stuck at this point so making a commit
This commit is contained in:
31
migrations/20241028221013_pivot_tables.up.sql
Normal file
31
migrations/20241028221013_pivot_tables.up.sql
Normal file
@@ -0,0 +1,31 @@
|
||||
-- Add up migration script here
|
||||
|
||||
CREATE TABLE "owner_history" (
|
||||
"id" BIGSERIAL NOT NULL,
|
||||
"aircraft_id" BIGSERIAL NOT NULL,
|
||||
"pilot_id" uuid NOT NULL,
|
||||
"since" timestamp DEFAULT CURRENT_TIMESTAMP,
|
||||
CONSTRAINT "owner_history_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- Pilot currently occupying/flying aircraft
|
||||
CREATE TABLE "pilot_current_aircraft" (
|
||||
"pilot_id" uuid NOT NULL,
|
||||
"aircraft_id" uuid NOT NULL,
|
||||
CONSTRAINT "pilot_aircraft_pkey" PRIMARY KEY ("pilot_id", "aircraft_id"),
|
||||
) WITH (oids = false);
|
||||
|
||||
CREATE TABLE "flight_log" (
|
||||
"id" BIGSERIAL NOT NULL,
|
||||
"pilot_id" uuid NOT NULL,
|
||||
"aircraft_id" uuid NOT NULL,
|
||||
"takeoff_time" timestamp DEFAULT CURRENT_TIMESTAMP,
|
||||
"takeoff_latitude_deg" NUMERIC NOT NULL,
|
||||
"takeoff_longitude_deg" NUMERIC NOT NULL,
|
||||
"takeoff_elevation_ft" NUMERIC NOT NULL DEFAULT 0,
|
||||
"landing" timestamp,
|
||||
"landing_latitude_deg" NUMERIC NOT NULL,
|
||||
"landing_longitude_deg" NUMERIC NOT NULL,
|
||||
"landing_elevation_ft" NUMERIC NOT NULL DEFAULT 0,
|
||||
CONSTRAINT "flight_log_pkey" PRIMARY KEY ("id")
|
||||
);
|
Reference in New Issue
Block a user