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

FilePurposeWhen to use
scripts/build-frontend.shBash wrapper that builds frontend/kundkort/ for distribution.Before bundling a release artefact.
scripts/generate-reports.tsGenerates 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.tsSchema 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.

FilePurposeWhen to use
scripts/add_cache_table.sqlCreates 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.sqlAdds 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.sqlBuilds 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.sqlPopulates 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.ts migrations are — they will not be tracked in schema_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-* and restore-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 the indexer/ 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.