mirror of
git://f0xx.org/ac/ac-deploy
synced 2026-07-29 03:38:07 +03:00
deploy: pre-populate migration tracking for already-applied migrations
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -23,6 +23,34 @@ CREATE TABLE IF NOT EXISTS schema_migrations (
|
|||||||
applied_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
applied_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||||
);
|
);
|
||||||
SQL
|
SQL
|
||||||
|
# Pre-populate tracking table for migrations already silently applied before this tracking was added.
|
||||||
|
# Detect by checking for a known column from each migration.
|
||||||
|
_existing=$(mariadb -u root -N -e "SELECT COUNT(*) FROM schema_migrations" "$db" 2>/dev/null || echo 0)
|
||||||
|
if [ "$_existing" -eq 0 ]; then
|
||||||
|
mariadb -u root "$db" <<'PRECHECK'
|
||||||
|
INSERT IGNORE INTO schema_migrations (migration) SELECT '004_ticket_workflow.sql'
|
||||||
|
FROM information_schema.columns
|
||||||
|
WHERE table_schema=DATABASE() AND table_name='tickets' AND column_name='workflow_state' LIMIT 1;
|
||||||
|
INSERT IGNORE INTO schema_migrations (migration) SELECT '005_ticket_attachments.sql'
|
||||||
|
FROM information_schema.tables
|
||||||
|
WHERE table_schema=DATABASE() AND table_name='ticket_attachments' LIMIT 1;
|
||||||
|
INSERT IGNORE INTO schema_migrations (migration) SELECT '006_graph_sessions.sql'
|
||||||
|
FROM information_schema.tables
|
||||||
|
WHERE table_schema=DATABASE() AND table_name='graph_sessions' LIMIT 1;
|
||||||
|
INSERT IGNORE INTO schema_migrations (migration) SELECT '007_remote_access.sql'
|
||||||
|
FROM information_schema.tables
|
||||||
|
WHERE table_schema=DATABASE() AND table_name='remote_access_sessions' LIMIT 1;
|
||||||
|
INSERT IGNORE INTO schema_migrations (migration) SELECT '008_graph_sessions_indexes.sql'
|
||||||
|
FROM information_schema.statistics
|
||||||
|
WHERE table_schema=DATABASE() AND table_name='graph_sessions' AND index_name='idx_gs_device' LIMIT 1;
|
||||||
|
INSERT IGNORE INTO schema_migrations (migration) SELECT '008_auth_email_2fa.sql'
|
||||||
|
FROM information_schema.tables
|
||||||
|
WHERE table_schema=DATABASE() AND table_name='auth_email_codes' LIMIT 1;
|
||||||
|
INSERT IGNORE INTO schema_migrations (migration) SELECT '009_rssh_sessions.sql'
|
||||||
|
FROM information_schema.tables
|
||||||
|
WHERE table_schema=DATABASE() AND table_name='rssh_sessions' LIMIT 1;
|
||||||
|
PRECHECK
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
migration_applied() {
|
migration_applied() {
|
||||||
|
|||||||
Reference in New Issue
Block a user