kinda stuck at this point so making a commit

This commit is contained in:
2024-10-31 00:19:02 +01:00
parent cd7d9fa3b7
commit 6d65463286
35 changed files with 44224 additions and 217 deletions

View File

@@ -0,0 +1,2 @@
-- Add down migration script here
DROP TABLE "airports";

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
-- Add down migration script here
DROP TABLE "ower_history";
DROP TABLE "aircrafts";

View File

@@ -0,0 +1,66 @@
-- Add up migration script here
CREATE TABLE "aircrafts" (
"id" uuid NOT NULL,
"registration" text NOT NULL,
"category" text NOT NULL,
"manufacturer" text NOT NULL,
"model" text NOT NULL,
"on_ground" boolean NOT NULL DEFAULT 1,
"created_at" timestamp DEFAULT CURRENT_TIMESTAMP,
"updated_at" timestamp DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "aircrafts_pkey" PRIMARY KEY ("id"),
CONSTRAINT "aircrafts_registration_unique" UNIQUE ("registration")
) WITH (oids = false);
CREATE TABLE "gps" (
"aircraft_id" uuid NOT NULL,
"latitude_deg" numeric NOT NULL,
"longitude_deg" numeric NOT NULL,
"elevation_ft" numeric NOT NULL,
"created_at" timestamp DEFAULT CURRENT_TIMESTAMP,
"updated_at" timestamp DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "gps_pkey" PRIMARY KEY ("aircraft_id")
)
CREATE TABLE "fuel" (
"aircraft_id" uuid NOT NULL,
"center_quantity" numeric,
"center_capacity" numeric,
"center2_quantity" numeric,
"center2_capacity" numeric,
"center3_quantity" numeric,
"center3_capacity" numeric,
"left_main_quantity" numeric,
"left_main_capacity" numeric,
"left_aux_quantity" numeric,
"left_aux_capacity" numeric,
"left_tip_quantity" numeric,
"left_tip_capacity" numeric,
"right_main_quantity" numeric,
"right_main_capacity" numeric,
"right_aux_quantity" numeric,
"right_aux_capacity" numeric,
"right_tip_quantity" numeric,
"right_tip_capacity" numeric,
"external1_quantity" numeric,
"external1_capacity" numeric,
"external2_quantity" numeric,
"external2_capacity" numeric,
"fuel_weight" numeric,
"created_at" timestamp DEFAULT CURRENT_TIMESTAMP,
"updated_at" timestamp DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "fuel_pkey" PRIMARY KEY ("aircraft_id")
)
-- If a player is in an aircraft that doesnt exist on our end, ask them to "purchace" it from the factory
-- What's the pricing going to look like though... hmm
-- If a pilot buys a new aircraft they need to get in it at least once to get all the fuel-cell data, we don't know beforehand how many tanks it has
-- after updating, the capacity should be > 0 to indicate which ones are used

View File

@@ -0,0 +1,2 @@
-- Add down migration script here
DROP TABLE "pilots";

View File

@@ -0,0 +1,25 @@
-- Add up migration script here
CREATE TABLE "pilots" (
"id" uuid NOT NULL, -- use the random-person-generator's id?
"user_id" uuid NOT NULL,
"full_name" text NOT NULL,
"date_of_birth" timestamp NOT NULL,
"gender" text NOT NULL,
"nationality" text NOT NULL,
"photo" text NOT NULL, -- base64 encoded image from RPG?
-- Pilot also needs to keep track of career progress
-- Flight lessons etc?
-- current location, i think we can use lat/lon to infer an airport location
"latitude_deg" numeric NOT NULL,
"longitude_deg" numeric NOT NULL,
CONSTRAINT "pilots_pkey" PRIMARY KEY ("id")
) WITH (oids = false);
-- Creating a new pilot from the following inputs:
-- Age (will determine year, but pick a random date) - depending if the RPG's API supports this
-- Gender
-- Nationality

View File

@@ -0,0 +1,4 @@
-- Add down migration script here
DROP TABLE "owner_history";
DROP TABLE "pilot_aircraft";
DROP TABLE "flight_log";

View 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")
);