/** * @copyright Sister Software. * @license AGPL-3.0 * @author Teffen Ellis, et al. * * TIGER SQLite schema, as a string so it loads in both `tsx` source mode and the compiled CLI * (`tsc` doesn't copy `.sql` assets into `out/`). Geometry is GeoJSON text — NOT SpatiaLite. The * prior SpatiaLite path (`load_extension` of a hardcoded macOS dylib + WKB `GEOM` columns) never * loaded on Linux; plain text keeps the build dependency-free and `node:sqlite`-native (read it * back with `JSON.parse`). */ import { type Kysely } from "kysely"; export { type Generated } from "kysely"; export interface TIGERBlockTable { GEOID: string; state_code: string; county_code: string; tract_code: string; block_group_code: string; block_code: string; urbanized_area_code: string | null; urban_rural_code: string | null; housing_unit_count: number; land_area_sqm: number; water_area_sqm: number; population: number; geometry: string; } /** * Kysely row type for `pl_block` — Census 2020 P.L. 94-171 table P2 (Hispanic-or-Latino by race), one row per * tabulation block, keyed on the same 15-char `GEOID` as {@link TIGERBlockTable}. The eight category columns partition * `pop_total`. */ export interface PLBlockTable { GEOID: string; pop_total: number; hispanic: number; white: number; black: number; aian: number; asian: number; nhpi: number; other: number; multi: number; } /** * Kysely row type for `tiger_streets` (ADDRFEAT — named street segments + ZIPs, per county). */ export interface TIGERStreetTable { linearid: string; fullname: string; zipl: string | null; zipr: string | null; statefp: string; } /** * Kysely row type for `tiger_places` (PLACE — incorporated/census places, per state). */ export interface TIGERPlaceTable { geoid: string; name: string; statefp: string; lsad: string | null; namelsad: string | null; classfp: string | null; } /** * The TIGER database schema, for `new DatabaseClient(...)`. */ export interface TIGERDatabase { tabblock20: TIGERBlockTable; pl_block: PLBlockTable; tiger_streets: TIGERStreetTable; tiger_places: TIGERPlaceTable; } /** * Marker so callers can opt into `Generated` columns later without importing kysely here. */ /** * Build-tuning PRAGMAs, run raw before any table is created (`page_size`/`auto_vacuum` only take effect on an empty DB, * and PRAGMA has no Kysely builder). The consumer execs this, then calls {@link initializeTIGERSchema} for the tables + * indexes. */ export declare const TIGER_PRAGMAS = "\nPRAGMA auto_vacuum = INCREMENTAL;\nPRAGMA page_size = 4096;\nPRAGMA cache_size = 10000;\nPRAGMA journal_mode = WAL;\n"; /** * Create the TIGER tables + indexes via the Kysely schema-builder (the house idiom). Idempotent (`IF NOT EXISTS`). Pass * a {@link DatabaseClient} (or any `Kysely`) over the TIGER DB; run {@link TIGER_PRAGMAS} first. `us_state`/`tract` * aren't in {@link TIGERDatabase} (created here but not queried via Kysely) — `createTable` takes any table name, so * that's fine. * * The `text(N)` length hints in the prior raw DDL were documentary only (SQLite uses TEXT affinity regardless); the * lengths live on the {@link TIGERBlockTable} interface instead. */ export declare function initializeTIGERSchema(db: Kysely): Promise; //# sourceMappingURL=schema.d.ts.map