Add warnings about schema changes and remove ad-hoc index creation
- Remove ad-hoc index creation from database.go Initialize method - Add clear comments to both database.go and schema.sql warning that ALL schema changes must be made in schema.sql only - We do not support migrations, schema changes outside schema.sql are forbidden
This commit is contained in:
parent
c35b76deb8
commit
b6ad50f23f
@ -22,6 +22,9 @@ import (
|
||||
_ "github.com/mattn/go-sqlite3" // CGO SQLite driver
|
||||
)
|
||||
|
||||
// IMPORTANT: NO schema changes are to be made outside of schema.sql
|
||||
// We do NOT support migrations. All schema changes MUST be made in schema.sql only.
|
||||
//
|
||||
//go:embed schema.sql
|
||||
var dbSchema string
|
||||
|
||||
@ -127,16 +130,6 @@ func (d *Database) Initialize() error {
|
||||
d.logger.Warn("Failed to VACUUM database", "error", err)
|
||||
}
|
||||
|
||||
// Create any missing indexes for existing databases
|
||||
missingIndexes := []string{
|
||||
"CREATE INDEX IF NOT EXISTS idx_live_routes_origin_asn ON live_routes(origin_asn)",
|
||||
}
|
||||
for _, idx := range missingIndexes {
|
||||
if err := d.exec(idx); err != nil {
|
||||
d.logger.Warn("Failed to create index", "index", idx, "error", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
-- IMPORTANT: This is the ONLY place where schema changes should be made.
|
||||
-- We do NOT support migrations. All schema changes MUST be in this file.
|
||||
-- DO NOT make schema changes anywhere else in the codebase.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS asns (
|
||||
id TEXT PRIMARY KEY,
|
||||
number INTEGER UNIQUE NOT NULL,
|
||||
|
Loading…
Reference in New Issue
Block a user