refactor(store): migration files + embed.FS

- migrations/001_init.sql + 002_target_extras.sql extraidos de schema inline
- store.go: applyMigrations() con embed.FS, splitSQLStatements, isIdempotentError
- aplica regla db_migrations.md (fn_registry/.claude/rules/)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-09 00:44:52 +02:00
parent 8e30e8cf29
commit ff5c17f7ff
3 changed files with 89 additions and 37 deletions
+26
View File
@@ -0,0 +1,26 @@
-- deploy_server initial schema. Tracks deploy targets (per app+host) and execution history.
CREATE TABLE IF NOT EXISTS deploy_targets (
app TEXT NOT NULL,
host TEXT NOT NULL,
remote_dir TEXT NOT NULL DEFAULT '',
binary_name TEXT NOT NULL DEFAULT '',
build_cmd TEXT NOT NULL DEFAULT '',
service_user TEXT NOT NULL DEFAULT '',
port INTEGER NOT NULL DEFAULT 0,
health_path TEXT NOT NULL DEFAULT '',
env TEXT NOT NULL DEFAULT '{}',
created_at TEXT NOT NULL,
PRIMARY KEY (app, host)
);
CREATE TABLE IF NOT EXISTS deploy_logs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
app TEXT NOT NULL,
host TEXT NOT NULL,
status TEXT NOT NULL,
trigger TEXT NOT NULL DEFAULT 'manual',
error TEXT NOT NULL DEFAULT '',
duration_ms INTEGER NOT NULL DEFAULT 0,
started_at TEXT NOT NULL
);
+6
View File
@@ -0,0 +1,6 @@
-- Extra deploy_targets columns: strategy, source_dir, branch, compose_files.
-- Aplicacion idempotente: store.go captura "duplicate column" para DBs preexistentes.
ALTER TABLE deploy_targets ADD COLUMN strategy TEXT NOT NULL DEFAULT 'systemd';
ALTER TABLE deploy_targets ADD COLUMN source_dir TEXT NOT NULL DEFAULT '';
ALTER TABLE deploy_targets ADD COLUMN branch TEXT NOT NULL DEFAULT 'main';
ALTER TABLE deploy_targets ADD COLUMN compose_files TEXT NOT NULL DEFAULT '';