deckhearth/migrations
varutasu ee7da9ac3a
feat(migrations): reconcile user profile missed by initial-schema backfill (B5) (#153)
Folds the union of DDL effects from `scripts/add-user-profile-columns.js`
(#8) and `scripts/add-user-profile-fields.js` (#9) into the migration
history so a brand-new Neon branch reaches structural parity with prod.

Captures:
- 16 ALTER TABLE users ADD COLUMN IF NOT EXISTS (first_name, last_name,
  username UNIQUE, profile_image_url, bio, avatar_url, favorite_games,
  collection_visibility, preferred_currency, cards_per_page, default_view,
  notifications_email, notifications_marketing, two_factor_enabled, theme,
  language). Per Finding 2, BOTH profile_image_url and avatar_url are kept
  (cleanup deferred to queued unify-user-avatar-column).
- 2 CREATE TABLE IF NOT EXISTS (user_settings, user_avatars) — FK to users
  with ON DELETE CASCADE; user_settings has UNIQUE(user_id, setting_key).
- 6 CREATE INDEX IF NOT EXISTS (idx_users_username, idx_users_email,
  idx_user_settings_user_id, idx_user_settings_key, idx_user_avatars_user_id,
  idx_user_avatars_active).
- 6 CHECK constraints wrapped in DO $$ EXCEPTION WHEN duplicate_object
  blocks (Postgres pre-15 has no ADD CONSTRAINT IF NOT EXISTS for CHECK):
  check_collection_visibility, check_preferred_currency, check_cards_per_page,
  check_default_view, check_theme, check_language.

Defaults-backfill DML from the historical script is intentionally NOT
replicated; column DEFAULTs handle fresh-env semantics and prod rows
already have the values from the historical run.

down() is a hard stub (rolling back would drop columns runtime code reads).

Convoy: reconcile-historical-add-scripts (Brief 5/7).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-14 08:18:20 -05:00
..
1779853647564_initial-schema.js feat(infra): adopt node-pg-migrate + backfill initial schema migration (#32) 2026-05-26 23:01:58 -05:00
1779853647565_add-pg-trgm-card-name-index.js feat(scanner): AI Gateway vision + Layer-1 Tesseract/pg_trgm OCR (#38) 2026-05-27 12:59:59 -05:00
1779853647566_add-scan-tables.js ci: run migrations against Postgres service container in CI (#64) 2026-06-02 11:01:18 -05:00
1779908094455_add-user-cards-scan-image-url.js feat(scanner): persist scan captures to Blob (Brief 3) (#44) 2026-05-27 13:57:26 -05:00
1780378340194_system-collection-description.js ci: run migrations against Postgres service container in CI (#64) 2026-06-02 11:01:18 -05:00
1781000000001_reconcile-cards-columns.js feat(migrations): reconcile cards columns missed by initial-schema backfill (B1) (#148) 2026-06-14 08:11:08 -05:00
1781000000002_reconcile-collections-columns.js feat(migrations): reconcile collections columns missed by initial-schema backfill (B2) (#150) 2026-06-14 08:18:05 -05:00
1781000000004_reconcile-favorites-system.js feat(migrations): reconcile favorites system missed by initial-schema backfill (B4) (#152) 2026-06-14 08:11:26 -05:00
1781000000005_reconcile-user-profile.js feat(migrations): reconcile user profile missed by initial-schema backfill (B5) (#153) 2026-06-14 08:18:20 -05:00
1781440700404_add-scryfall-bulk-columns.js feat(catalog): Scryfall bulk data import + Tagger community tags 2026-06-14 07:51:39 -05:00
1781440721350_add-tagger-tables.js feat(catalog): Scryfall bulk data import + Tagger community tags 2026-06-14 07:51:39 -05:00