feat(db): normalize star systems into multi-table schema with GJ primary keys
Replaces flat star_systems table with 7 normalized tables: star_systems, system_gates (with hop_distance_from_gateway), system_history, historical_events (1:N), system_economy, system_factions, system_culture. Primary key is now the GJ astronomical ID (e.g., "GJ 244A") — S-number identifiers removed entirely. The astronomical_id column is dropped as redundant. Database moved to server/data/systems.db (ships with game). 10 core systems fully populated with structured data. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+2
-103
@@ -95,107 +95,6 @@ CREATE INDEX IF NOT EXISTS idx_decision_refs_source ON decision_refs(source_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_decision_refs_target ON decision_refs(target_id);
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- Star Systems Wiki Mirror
|
||||
-- Populated by: python3 tooling/db/wiki_sync.py sync
|
||||
-- Source: wiki/star-systems/*/index.md (YAML frontmatter)
|
||||
-- Star Systems live in a separate database: server/data/systems.db
|
||||
-- Schema: server/data/systems-schema.sql
|
||||
-- ---------------------------------------------------------------------------
|
||||
|
||||
CREATE TABLE IF NOT EXISTS star_systems (
|
||||
-- I. Identity and Location
|
||||
system_id TEXT PRIMARY KEY,
|
||||
astronomical_id TEXT NOT NULL,
|
||||
proper_name TEXT,
|
||||
system_name TEXT,
|
||||
star_type TEXT,
|
||||
geographic_sector TEXT,
|
||||
geographic_band TEXT,
|
||||
political_zone TEXT,
|
||||
|
||||
-- II. Physical Character
|
||||
habitable_planet_count INTEGER,
|
||||
inhabited_planet_count INTEGER,
|
||||
asteroid_belt TEXT,
|
||||
gas_giant TEXT,
|
||||
habitability_profile TEXT,
|
||||
|
||||
-- III. Gate Infrastructure
|
||||
horizon_station INTEGER, -- boolean 0/1
|
||||
aperture_count INTEGER,
|
||||
gate_connections INTEGER,
|
||||
gate_topology TEXT,
|
||||
span_gate_network TEXT,
|
||||
|
||||
-- IV. Settlement History
|
||||
settlement_wave TEXT,
|
||||
founding_motivation TEXT,
|
||||
founding_culture_primary TEXT,
|
||||
founding_culture_secondary TEXT,
|
||||
cultural_persistence TEXT,
|
||||
historical_event TEXT,
|
||||
historical_event_age_years INTEGER,
|
||||
religious_status TEXT,
|
||||
religious_generation_count INTEGER,
|
||||
|
||||
-- V. Economic Life
|
||||
economic_tier TEXT,
|
||||
population TEXT,
|
||||
economic_base_primary TEXT,
|
||||
economic_base_secondary TEXT,
|
||||
distribution_index TEXT,
|
||||
imprint_access TEXT,
|
||||
supply_dependency TEXT,
|
||||
|
||||
-- VI. Governance
|
||||
governance_type TEXT,
|
||||
dominant_faction TEXT,
|
||||
primary_fault_line TEXT,
|
||||
secondary_fault_line TEXT,
|
||||
|
||||
-- VII. Faction Presence
|
||||
assembly_presence TEXT,
|
||||
commission_presence TEXT,
|
||||
syndic_presence TEXT,
|
||||
syndic_type TEXT,
|
||||
separatist_presence TEXT,
|
||||
separatist_type TEXT,
|
||||
institute_presence TEXT,
|
||||
guardians_presence TEXT,
|
||||
faction_notes TEXT,
|
||||
|
||||
-- VIII. Cultural Voice
|
||||
cultural_register TEXT,
|
||||
cultural_register_secondary TEXT,
|
||||
ambient_anxiety TEXT,
|
||||
local_pride TEXT,
|
||||
atmospheric_tone TEXT,
|
||||
atmospheric_tone_secondary TEXT,
|
||||
active_situation TEXT,
|
||||
silence_threshold TEXT,
|
||||
silence_topic TEXT,
|
||||
|
||||
-- IX. Political Character
|
||||
earth_alignment TEXT,
|
||||
earth_proximity TEXT,
|
||||
earth_tension TEXT,
|
||||
|
||||
-- X. Narrative Profile
|
||||
primary_archetype TEXT,
|
||||
secondary_archetype TEXT,
|
||||
narrative_notable TEXT,
|
||||
narrative_hook TEXT,
|
||||
generation_priority TEXT,
|
||||
|
||||
-- XI. Content Notes
|
||||
stability_index TEXT,
|
||||
system_volatility TEXT,
|
||||
cultural_corridor TEXT,
|
||||
calibration_note TEXT,
|
||||
|
||||
synced_at TEXT DEFAULT (datetime('now'))
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_star_systems_astro ON star_systems(astronomical_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_star_systems_sector ON star_systems(geographic_sector);
|
||||
CREATE INDEX IF NOT EXISTS idx_star_systems_wave ON star_systems(settlement_wave);
|
||||
CREATE INDEX IF NOT EXISTS idx_star_systems_topology ON star_systems(gate_topology);
|
||||
CREATE INDEX IF NOT EXISTS idx_star_systems_star_type ON star_systems(star_type);
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
-- Star Systems Database Schema — server/data/systems.db
|
||||
-- Source of truth for all structured star system data.
|
||||
-- Authored via tooling pipeline; wiki pages are generated views.
|
||||
-- Shipped with the game — read-only from the server's perspective.
|
||||
--
|
||||
-- Rebuild: tooling/process-wiki-system-changes --rebuild-db
|
||||
|
||||
PRAGMA journal_mode=WAL;
|
||||
PRAGMA foreign_keys=ON;
|
||||
|
||||
-- Core identity, physical character, political character
|
||||
CREATE TABLE IF NOT EXISTS star_systems (
|
||||
system_id TEXT PRIMARY KEY, -- GJ catalog number (e.g., "GJ 244A")
|
||||
proper_name TEXT,
|
||||
system_name TEXT,
|
||||
star_type TEXT,
|
||||
spectral_class TEXT,
|
||||
dist_ly REAL,
|
||||
geographic_sector TEXT,
|
||||
geographic_band TEXT,
|
||||
political_zone TEXT,
|
||||
|
||||
-- Physical character
|
||||
habitable_planet_count INTEGER,
|
||||
inhabited_planet_count INTEGER,
|
||||
asteroid_belt INTEGER, -- boolean 0/1
|
||||
gas_giant INTEGER, -- boolean 0/1
|
||||
habitability_profile TEXT,
|
||||
|
||||
-- Political character
|
||||
earth_alignment TEXT,
|
||||
earth_proximity TEXT,
|
||||
earth_tension TEXT,
|
||||
|
||||
-- Content notes
|
||||
stability_index INTEGER,
|
||||
system_volatility TEXT,
|
||||
cultural_corridor TEXT,
|
||||
generation_priority TEXT,
|
||||
|
||||
updated_at TEXT DEFAULT (datetime('now'))
|
||||
);
|
||||
|
||||
-- Gate infrastructure — queried independently for pathfinding/topology
|
||||
CREATE TABLE IF NOT EXISTS system_gates (
|
||||
system_id TEXT PRIMARY KEY REFERENCES star_systems(system_id),
|
||||
horizon_station INTEGER, -- boolean 0/1
|
||||
aperture_count INTEGER,
|
||||
gate_connections INTEGER,
|
||||
gate_topology TEXT,
|
||||
hop_distance_from_gateway INTEGER,
|
||||
span_gate_network TEXT
|
||||
);
|
||||
|
||||
-- Settlement history
|
||||
CREATE TABLE IF NOT EXISTS system_history (
|
||||
system_id TEXT PRIMARY KEY REFERENCES star_systems(system_id),
|
||||
settlement_wave TEXT,
|
||||
founding_motivation TEXT,
|
||||
founding_culture_primary TEXT,
|
||||
founding_culture_secondary TEXT,
|
||||
cultural_persistence TEXT,
|
||||
religious_status TEXT,
|
||||
religious_generation_count INTEGER
|
||||
);
|
||||
|
||||
-- Historical events — proper 1:N child table
|
||||
CREATE TABLE IF NOT EXISTS historical_events (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
system_id TEXT NOT NULL REFERENCES star_systems(system_id),
|
||||
event_type TEXT NOT NULL,
|
||||
age_years INTEGER,
|
||||
sort_order INTEGER NOT NULL DEFAULT 0 -- 0 = most recent
|
||||
);
|
||||
|
||||
-- Economic life
|
||||
CREATE TABLE IF NOT EXISTS system_economy (
|
||||
system_id TEXT PRIMARY KEY REFERENCES star_systems(system_id),
|
||||
economic_tier INTEGER,
|
||||
population INTEGER,
|
||||
economic_base_primary TEXT,
|
||||
economic_base_secondary TEXT,
|
||||
distribution_index TEXT,
|
||||
imprint_access TEXT
|
||||
);
|
||||
|
||||
-- Faction presence
|
||||
CREATE TABLE IF NOT EXISTS system_factions (
|
||||
system_id TEXT PRIMARY KEY REFERENCES star_systems(system_id),
|
||||
governance_type TEXT,
|
||||
dominant_faction TEXT,
|
||||
primary_fault_line TEXT,
|
||||
secondary_fault_line TEXT,
|
||||
assembly_presence TEXT,
|
||||
commission_presence TEXT,
|
||||
syndic_presence TEXT,
|
||||
syndic_type TEXT,
|
||||
separatist_presence TEXT,
|
||||
separatist_type TEXT,
|
||||
institute_presence TEXT,
|
||||
guardians_presence TEXT
|
||||
);
|
||||
|
||||
-- Cultural voice
|
||||
CREATE TABLE IF NOT EXISTS system_culture (
|
||||
system_id TEXT PRIMARY KEY REFERENCES star_systems(system_id),
|
||||
cultural_register TEXT,
|
||||
cultural_register_secondary TEXT,
|
||||
ambient_anxiety TEXT,
|
||||
local_pride TEXT,
|
||||
atmospheric_tone TEXT,
|
||||
atmospheric_tone_secondary TEXT,
|
||||
active_situation TEXT,
|
||||
silence_threshold TEXT,
|
||||
primary_archetype TEXT,
|
||||
secondary_archetype TEXT,
|
||||
narrative_notable INTEGER -- boolean 0/1
|
||||
);
|
||||
|
||||
-- Authored prose (supply_dependency, faction_notes, silence_topic,
|
||||
-- narrative_hook, calibration_note) lives in wiki markdown files only.
|
||||
-- No DB mirror — read the file if you need the text.
|
||||
|
||||
-- Indexes
|
||||
-- astronomical_id removed: system_id IS the GJ catalog number
|
||||
CREATE INDEX IF NOT EXISTS idx_star_systems_sector ON star_systems(geographic_sector);
|
||||
CREATE INDEX IF NOT EXISTS idx_star_systems_wave ON system_history(settlement_wave);
|
||||
CREATE INDEX IF NOT EXISTS idx_star_systems_topology ON system_gates(gate_topology);
|
||||
CREATE INDEX IF NOT EXISTS idx_star_systems_star_type ON star_systems(star_type);
|
||||
CREATE INDEX IF NOT EXISTS idx_star_systems_volatility ON star_systems(system_volatility);
|
||||
CREATE INDEX IF NOT EXISTS idx_historical_events_system ON historical_events(system_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_system_factions_dominant ON system_factions(dominant_faction);
|
||||
CREATE INDEX IF NOT EXISTS idx_system_economy_tier ON system_economy(economic_tier);
|
||||
CREATE INDEX IF NOT EXISTS idx_system_culture_archetype ON system_culture(primary_archetype);
|
||||
Binary file not shown.
Reference in New Issue
Block a user