From f692b45926bfbee412cf4a762bb7ebe3754f3be3 Mon Sep 17 00:00:00 2001 From: Nicholai Date: Thu, 18 Sep 2025 20:21:44 -0600 Subject: [PATCH] CI: trigger workflow run and add budgets/docs; prepare branch ci-run-20250918-2021 --- .gitignore | 3 +++ scripts/migrate-latest.mjs | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 scripts/migrate-latest.mjs diff --git a/.gitignore b/.gitignore index 95a9b33a7..b3d77bb11 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,6 @@ temp/** # database backups (local exports) backups/ + +# wrangler local state (do not commit) +.wrangler/ diff --git a/scripts/migrate-latest.mjs b/scripts/migrate-latest.mjs new file mode 100644 index 000000000..c13eeac7d --- /dev/null +++ b/scripts/migrate-latest.mjs @@ -0,0 +1,33 @@ +#!/usr/bin/env node +import { readdirSync } from 'node:fs'; +import { spawnSync } from 'node:child_process'; +import { join } from 'node:path'; + +const MIGRATIONS_DIR = join(process.cwd(), 'sql', 'migrations'); +const DB_NAME = 'united-tattoo'; +const useRemote = process.argv.includes('--remote'); + +// Gather UP migration files (exclude *_down.sql), sorted lexicographically +const files = readdirSync(MIGRATIONS_DIR) + .filter((f) => f.endsWith('.sql') && !f.endsWith('_down.sql')) + .sort(); + +if (files.length === 0) { + console.log('No migration files found in sql/migrations.'); + process.exit(0); +} + +for (const f of files) { + const full = join(MIGRATIONS_DIR, f); + const args = ['d1', 'execute', DB_NAME, '--file', full]; + if (useRemote) args.splice(2, 0, '--remote'); + console.log(`\nApplying migration: ${f}${useRemote ? ' [--remote]' : ''}`); + const res = spawnSync('wrangler', args, { stdio: 'inherit' }); + if (res.status !== 0) { + console.error(`Migration failed for ${f}. Aborting.`); + process.exit(res.status ?? 1); + } +} + +console.log('\nAll migrations applied successfully.'); +