This commit is contained in:
@@ -57,6 +57,18 @@ CREATE TABLE IF NOT EXISTS script_interpreters (
|
||||
);
|
||||
`
|
||||
|
||||
const CreateScriptsTable = `
|
||||
CREATE TABLE IF NOT EXISTS scripts (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
path TEXT NOT NULL UNIQUE,
|
||||
content TEXT NOT NULL DEFAULT '',
|
||||
interpreter_id INTEGER NOT NULL,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (interpreter_id) REFERENCES script_interpreters(id)
|
||||
);
|
||||
`
|
||||
|
||||
const CreateLogsTable = `
|
||||
CREATE TABLE IF NOT EXISTS logs (
|
||||
timestamp DateTime64(3) DEFAULT now(),
|
||||
|
||||
@@ -44,5 +44,10 @@ func Open(path string) (*sql.DB, error) {
|
||||
log.Println("[sqlite] is_active column migration applied")
|
||||
}
|
||||
|
||||
// Create scripts table if not exists
|
||||
if _, err := db.Exec(CreateScriptsTable); err != nil {
|
||||
return nil, fmt.Errorf("migrate scripts: %w", err)
|
||||
}
|
||||
|
||||
return db, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user