@@ -1015,6 +1015,44 @@ var migrations = []Migration{
10151015 return nil
10161016 },
10171017 },
1018+ {
1019+ Version : 26 ,
1020+ Description : "Add Iridium pass predictor tables: locations and TLE cache" ,
1021+ Up : func (db * sql.DB ) error {
1022+ stmts := []string {
1023+ // iridium_locations: ground stations for pass prediction
1024+ `CREATE TABLE IF NOT EXISTS iridium_locations (
1025+ id INTEGER PRIMARY KEY AUTOINCREMENT,
1026+ name TEXT NOT NULL,
1027+ lat REAL NOT NULL,
1028+ lon REAL NOT NULL,
1029+ alt_m REAL NOT NULL DEFAULT 0,
1030+ builtin INTEGER NOT NULL DEFAULT 0,
1031+ created_at INTEGER NOT NULL DEFAULT (CAST(strftime('%s','now') AS INTEGER))
1032+ )` ,
1033+ // Seed built-in locations
1034+ `INSERT OR IGNORE INTO iridium_locations (name, lat, lon, alt_m, builtin) VALUES ('Leiden', 52.160, 4.497, 0, 1)` ,
1035+ `INSERT OR IGNORE INTO iridium_locations (name, lat, lon, alt_m, builtin) VALUES ('Thessaloniki', 40.629, 22.947, 0, 1)` ,
1036+
1037+ // iridium_tle_cache: cached TLE data fetched from Celestrak
1038+ `CREATE TABLE IF NOT EXISTS iridium_tle_cache (
1039+ id INTEGER PRIMARY KEY AUTOINCREMENT,
1040+ satellite_name TEXT NOT NULL,
1041+ line1 TEXT NOT NULL,
1042+ line2 TEXT NOT NULL,
1043+ fetched_at INTEGER NOT NULL -- Unix epoch seconds
1044+ )` ,
1045+ `CREATE INDEX IF NOT EXISTS idx_tle_cache_name ON iridium_tle_cache(satellite_name)` ,
1046+ }
1047+ for _ , stmt := range stmts {
1048+ if _ , err := db .Exec (stmt ); err != nil {
1049+ return fmt .Errorf ("migration 26 failed: %w\n Statement: %s" , err , stmt )
1050+ }
1051+ }
1052+ log .Info ().Msg ("Migration 26: Created iridium_locations and iridium_tle_cache tables" )
1053+ return nil
1054+ },
1055+ },
10181056}
10191057
10201058// isDuplicateColumnError checks if an error is a "duplicate column" error
0 commit comments