Catch-all for scripts/ files that do not fit Import Scripts, Archive Scripts, Backup Scripts, or Debug Scripts. One line per file: purpose and when to use.
TypeScript / shell utilities
| File | Purpose | When to use |
|---|---|---|
scripts/build-frontend.sh | Bash wrapper that builds frontend/kundkort/ for distribution. | Before bundling a release artefact. |
scripts/generate-reports.ts | Generates rich HTML “kundkort” reports against the canonical field spec (orgnr, SNI, hemsida, sammanfattning, financials per year, contacts per role, etc.). 887 lines. | When you need a static HTML snapshot of an enrichment run for stakeholder review. |
scripts/migrate.ts | Schema migration runner. Already covered in detail in Schema Migrations and listed under Import Scripts for completeness. | Always — the npm alias is bun run migrate. |
Standalone SQL files in scripts/
These are not run by migrate.ts. They live in scripts/ because they pre-date the formal migrations folder or are one-off DDL meant to be applied manually with psql -f.
| File | Purpose | When to use |
|---|---|---|
scripts/add_cache_table.sql | Creates enrichment_cache (GDPR-compliant cache with TTL + audit). | Only on legacy DBs where the cache table is missing; modern DBs get it via the migrations folder. |
scripts/migrate_scb_schema_20260307.sql | Adds SCB-specific columns: SNI codes, CO address, advertising_block, entity_status. | Historical — the equivalent is now part of migrations/. Kept for forensic reference. |
scripts/database_migration_unified_search.sql | Builds the unified-companies view, enhanced leads table, full-text search indexes, pg_trgm fuzzy search. 465 lines. | One-shot DDL upgrade. Apply with psql -h localhost -p 5433 -U user -d enrichnodedb -f scripts/database_migration_unified_search.sql. |
scripts/populate_enhanced_leads.sql | Populates enhanced_leads from unified_companies after the migration above runs. | Run after database_migration_unified_search.sql, never before. |
Warning
The four SQL files above are NOT idempotent in the same way
migrate.tsmigrations are — they will not be tracked inschema_migrations. Re-running them on an already-migrated DB can fail or duplicate data. Confirm state with\d <table>first.
Scripts whose purpose is unambiguous from filename
These were inspected but warrant no dedicated row beyond what their name says. Cross-references resolve to the relevant note:
- All
archive-*andrestore-from-archive,verify-archive→ see Archive Scripts. backup-database.ts→ see Backup Scripts.- All
test-*,clear-*,check-*,verify-api,inspect-wins,enrich-*,run-enrich,benchmark-domain-discovery,fix-vendfox-domain,update-vendfox-domain→ see Debug Scripts. - All
import-*and theindexer/subfolder → see Import Scripts.
Scripts with unclear purpose
None. Every file under scripts/ (38 total) was inspected and accounted for.
See also
Import Scripts, Archive Scripts, Backup Scripts, Debug Scripts, Schema Migrations, Frontend Build.