CREATE TABLE IF NOT EXISTS plans (
    id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
    mission_id UUID NOT NULL REFERENCES missions(mission_id) ON DELETE CASCADE,
    plan_start TIMESTAMP WITH TIME ZONE,
    plan_stop TIMESTAMP WITH TIME ZONE,
    plan_number BIGINT NOT NULL,
    revolution BIGINT NOT NULL
);

CREATE INDEX IF NOT EXISTS idx_plans_mission_id ON plans(mission_id);
CREATE INDEX IF NOT EXISTS idx_plans_plan_number ON plans(plan_number);
