deckhearth/migrations/1781442329511_add-catalog-sync-log.js
Randall Stillwell ec9bb2b93e feat(catalog): unified multi-game bulk sync + schema map update
Ship Pokemon and Lorcana bulk import libs/scripts, unified weekly cron
sync across MTG/Pokemon/Lorcana with per-game error isolation and
catalog_sync_log telemetry. Admin UI adds Unified/Incremental/Bulk MTG modes.

- Rename reconcile migrations to 1781442330* timestamps so they apply
  after bulk-data migrations without node-pg-migrate ordering conflicts
- Add Lorcana set-code normalization + orphan cleanup migrations
- Drop stricter user_cards_user_card_unique (keep 3-column foil unique)
- Update docs/SCHEMA_MAP.md for tags, card_tags, catalog_sync_log, bulk columns

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-14 08:22:19 -05:00

24 lines
773 B
JavaScript

/**
* Track per-game catalog sync runs (staleness, upsert counts, errors).
*/
export const shorthands = undefined;
export const up = (pgm) => {
pgm.createTable('catalog_sync_log', {
id: 'id',
game: { type: 'varchar(20)', notNull: true },
mode: { type: 'varchar(20)', notNull: true },
upserted: { type: 'integer', notNull: true, default: 0 },
errors: { type: 'integer', notNull: true, default: 0 },
source_updated_at: { type: 'timestamptz' },
ran_at: { type: 'timestamptz', notNull: true, default: pgm.func('CURRENT_TIMESTAMP') },
details: { type: 'jsonb' },
});
pgm.createIndex('catalog_sync_log', 'game');
pgm.createIndex('catalog_sync_log', 'ran_at');
};
export const down = (pgm) => {
pgm.dropTable('catalog_sync_log');
};