dev: automated commit - 2025-08-10 18:25:00

This commit is contained in:
Mariano Z. 2025-08-10 18:25:00 -03:00
parent 81967b4d8e
commit f24ef7b8fa
3 changed files with 49 additions and 22 deletions

View file

@ -10,6 +10,32 @@ func InitSchema(db *sql.DB) error {
// Create a new Queries instance
q := New(db)
// Execute the initialization query
return q.InitSchema(context.Background())
// Execute the config table creation
if err := q.InitSchema(context.Background()); err != nil {
return err
}
// Create static_records table separately
_, err := db.ExecContext(context.Background(), `
CREATE TABLE IF NOT EXISTS static_records (
record_id TEXT PRIMARY KEY,
record_name TEXT NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
`)
if err != nil {
return err
}
// Insert default config if none exists
_, err = db.ExecContext(context.Background(), `
INSERT OR IGNORE INTO config (api_token, zone_id, domain, update_period)
SELECT '', '', 'mz.uy', '0 */6 * * *'
WHERE NOT EXISTS (SELECT 1 FROM config);
`)
if err != nil {
return err
}
return nil
}