Files
linkder/packages/db/scripts/fix-postgis.mjs
T
serfowiandClaude Opus 5 19623bcccb M0: foundation — monorepo, PostGIS schema, deck query, app shell
Greenfield scaffold for Linkder, a swipe-to-hire marketplace for local
professional services.

- pnpm/turbo monorepo: apps/web, packages/{shared,db}
- Postgres 16 + PostGIS via docker compose (ports 5442/6389 to avoid
  clashing with other local stacks)
- Drizzle schema, 23 tables, geography(Point,4326) with GiST indexes
- Domain core in packages/shared: integer-cent money, status transition
  graphs, deck ranking weights, cancellation policy — 46 unit tests
- Deck query: filtering in Postgres on the GiST index, ranking in JS so
  the weights stay tunable — 18 integration tests against a seeded DB
- Deterministic seed placing pros at known distances, including three
  that must NOT appear on a deck (out of radius, unverified, away)
- Next.js 15 app shell with a working swipe deck
- CI: typecheck, lint, test, build against live postgres+redis

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 13:32:35 -04:00

30 lines
1.0 KiB
JavaScript

/**
* drizzle-kit quotes any type name it does not recognise, so a geography column
* is emitted as "geography(Point,4326)" — a quoted identifier, which Postgres
* rejects with `type "geography(Point,4326)" does not exist`.
*
* This unquotes them. It runs automatically as part of `pnpm db:generate`;
* if you ever run `drizzle-kit generate` directly, run this afterwards.
*/
import { readdir, readFile, writeFile } from 'node:fs/promises';
import { join } from 'node:path';
const DIR = 'drizzle';
const QUOTED = /"(geography|geometry)\(([^)"]*)\)"/g;
const files = (await readdir(DIR)).filter((f) => f.endsWith('.sql'));
let patched = 0;
for (const file of files) {
const path = join(DIR, file);
const before = await readFile(path, 'utf8');
const after = before.replace(QUOTED, '$1($2)');
if (after !== before) {
await writeFile(path, after);
patched++;
console.log(` unquoted PostGIS types in ${file}`);
}
}
console.log(patched ? `PostGIS fixup applied to ${patched} file(s)` : 'PostGIS fixup: nothing to do');