-- StarPanel V3 -> V4 reference migration (SQLite).
-- db.php applies these customer-column additions safely by checking PRAGMA table_info first.
-- Do not replay ALTER TABLE statements manually against a database already migrated by PHP.
ALTER TABLE customers ADD COLUMN show_billing INTEGER DEFAULT 1;
ALTER TABLE customers ADD COLUMN enabled INTEGER NOT NULL DEFAULT 1;
ALTER TABLE customers ADD COLUMN updated_at TEXT;
ALTER TABLE customers ADD COLUMN kit_id TEXT;
ALTER TABLE customers ADD COLUMN last_sync TEXT;

CREATE INDEX IF NOT EXISTS idx_customers_sl ON customers(service_line);
CREATE INDEX IF NOT EXISTS idx_fails_ip_t ON fails(ip,t);
CREATE TABLE IF NOT EXISTS sync_errors (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  t INTEGER NOT NULL,
  detail TEXT NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_sync_errors_t ON sync_errors(t);
