base sys done. shift to vs code

This commit is contained in:
Duncan Auld
2025-06-30 05:17:50 +00:00
parent 05f87e04f9
commit 2c49d7cd5c
10 changed files with 292 additions and 0 deletions

44
db/schema.sql Normal file
View File

@@ -0,0 +1,44 @@
-- Enable extensions
CREATE EXTENSION IF NOT EXISTS postgis;
CREATE EXTENSION IF NOT EXISTS timescaledb;
-- Main object catalog (replaces 'satellites')
CREATE TABLE objects (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
norad_id INT UNIQUE NOT NULL,
intl_designator TEXT,
launch_date DATE,
orbit_type TEXT
);
CREATE TABLE orbits (
object_id INT REFERENCES objects(id),
ts TIMESTAMPTZ NOT NULL,
position GEOGRAPHY(POINT, 4326),
altitude_km DOUBLE PRECISION,
velocity_kms DOUBLE PRECISION,
PRIMARY KEY (object_id, ts)
);
SELECT create_hypertable('orbits', 'ts', if_not_exists => TRUE);
-- Conjunction Data Messages / alerts
CREATE TABLE conjunctions (
id SERIAL PRIMARY KEY,
primary_object INT REFERENCES objects(id),
secondary_object INT,
tca TIMESTAMPTZ, -- Time of Closest Approach
miss_distance_km DOUBLE PRECISION,
risk_level TEXT,
poc DOUBLE PRECISION -- Probability of Collision
);
-- Re-entry prediction windows and footprints
CREATE TABLE reentry_predictions (
id SERIAL PRIMARY KEY,
object_id INT REFERENCES objects(id),
window_start TIMESTAMPTZ,
window_end TIMESTAMPTZ,
footprint GEOGRAPHY(POLYGON, 4326),
notes TEXT
);