Public Access
1
0

feat: migrate app to local Fastify and Postgres stack

Replace Supabase auth and search runtime with a local Fastify API, PostgreSQL/PostGIS schema, and local session handling. Scaffold the worker and deep-research foundations while keeping the existing research, dashboard, and map flows running on the new backend.
This commit is contained in:
pguerrerox
2026-03-27 13:56:54 +00:00
parent 0e4910805a
commit a1ba5ee093
44 changed files with 3756 additions and 1128 deletions
+54
View File
@@ -0,0 +1,54 @@
import 'dotenv/config';
import { readdir, readFile } from 'node:fs/promises';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { getDbPool } from '../../server/src/db/pool.js';
const currentDir = path.dirname(fileURLToPath(import.meta.url));
const migrationsDir = path.resolve(currentDir, '../migrations');
async function run() {
const pool = getDbPool();
const client = await pool.connect();
try {
await client.query(`
create table if not exists public.schema_migrations (
id text primary key,
applied_at timestamptz not null default now()
)
`);
const appliedRows = await client.query<{ id: string }>('select id from public.schema_migrations');
const appliedIds = new Set(appliedRows.rows.map((row) => row.id));
const migrationFiles = (await readdir(migrationsDir))
.filter((entry) => entry.endsWith('.sql'))
.sort((left, right) => left.localeCompare(right));
for (const migrationFile of migrationFiles) {
if (appliedIds.has(migrationFile)) {
continue;
}
const migrationPath = path.join(migrationsDir, migrationFile);
const sql = await readFile(migrationPath, 'utf8');
console.log(`Applying migration ${migrationFile}`);
await client.query('begin');
await client.query(sql);
await client.query('insert into public.schema_migrations (id) values ($1)', [migrationFile]);
await client.query('commit');
}
console.log('Migrations complete');
} catch (error) {
await client.query('rollback');
throw error;
} finally {
client.release();
await pool.end();
}
}
await run();