|
| 1 | +import { sqliteTable, text, integer, blob } from 'drizzle-orm/sqlite-core'; |
| 2 | + |
| 3 | +// Static Collections (Hydrated from Snapshot) |
| 4 | + |
| 5 | +export const quests = sqliteTable('quests', { |
| 6 | + id: integer('id').primaryKey({ autoIncrement: true }), |
| 7 | + external_id: text('external_id').notNull().unique(), |
| 8 | + name: text('name').notNull(), |
| 9 | + description: text('description'), |
| 10 | + trader: text('trader'), |
| 11 | + objectives: blob('objectives', { mode: 'json' }), // JSONB representation |
| 12 | + reward_item_ids: blob('reward_item_ids', { mode: 'json' }), |
| 13 | + xp: integer('xp'), |
| 14 | + data: blob('data', { mode: 'json' }), // Full raw JSON |
| 15 | + synced_at: integer('synced_at', { mode: 'timestamp' }).notNull(), |
| 16 | +}); |
| 17 | + |
| 18 | +export const items = sqliteTable('items', { |
| 19 | + id: integer('id').primaryKey({ autoIncrement: true }), |
| 20 | + external_id: text('external_id').notNull().unique(), |
| 21 | + name: text('name').notNull(), |
| 22 | + description: text('description'), |
| 23 | + type: text('type'), |
| 24 | + image_url: text('image_url'), |
| 25 | + image_filename: text('image_filename'), |
| 26 | + data: blob('data', { mode: 'json' }), |
| 27 | + synced_at: integer('synced_at', { mode: 'timestamp' }).notNull(), |
| 28 | +}); |
| 29 | + |
| 30 | +export const skillNodes = sqliteTable('skill_nodes', { |
| 31 | + id: integer('id').primaryKey({ autoIncrement: true }), |
| 32 | + external_id: text('external_id').notNull().unique(), |
| 33 | + name: text('name').notNull(), |
| 34 | + description: text('description'), |
| 35 | + impacted_skill: text('impacted_skill'), |
| 36 | + category: text('category'), |
| 37 | + max_points: integer('max_points'), |
| 38 | + icon_name: text('icon_name'), |
| 39 | + is_major: integer('is_major', { mode: 'boolean' }), |
| 40 | + data: blob('data', { mode: 'json' }), |
| 41 | + synced_at: integer('synced_at', { mode: 'timestamp' }).notNull(), |
| 42 | +}); |
| 43 | + |
| 44 | +export const hideoutModules = sqliteTable('hideout_modules', { |
| 45 | + id: integer('id').primaryKey({ autoIncrement: true }), |
| 46 | + external_id: text('external_id').notNull().unique(), |
| 47 | + name: text('name').notNull(), |
| 48 | + description: text('description'), |
| 49 | + max_level: integer('max_level'), |
| 50 | + levels: blob('levels', { mode: 'json' }), |
| 51 | + data: blob('data', { mode: 'json' }), |
| 52 | + synced_at: integer('synced_at', { mode: 'timestamp' }).notNull(), |
| 53 | +}); |
| 54 | + |
| 55 | +export const bots = sqliteTable('bots', { |
| 56 | + id: integer('id').primaryKey({ autoIncrement: true }), |
| 57 | + external_id: text('external_id').notNull().unique(), |
| 58 | + name: text('name').notNull(), |
| 59 | + description: text('description'), |
| 60 | + data: blob('data', { mode: 'json' }), |
| 61 | + synced_at: integer('synced_at', { mode: 'timestamp' }).notNull(), |
| 62 | +}); |
| 63 | + |
| 64 | +export const maps = sqliteTable('maps', { |
| 65 | + id: integer('id').primaryKey({ autoIncrement: true }), |
| 66 | + external_id: text('external_id').notNull().unique(), |
| 67 | + name: text('name').notNull(), |
| 68 | + description: text('description'), |
| 69 | + data: blob('data', { mode: 'json' }), |
| 70 | + synced_at: integer('synced_at', { mode: 'timestamp' }).notNull(), |
| 71 | +}); |
| 72 | + |
| 73 | +export const traders = sqliteTable('traders', { |
| 74 | + id: integer('id').primaryKey({ autoIncrement: true }), |
| 75 | + external_id: text('external_id').notNull().unique(), |
| 76 | + name: text('name').notNull(), |
| 77 | + description: text('description'), |
| 78 | + data: blob('data', { mode: 'json' }), |
| 79 | + synced_at: integer('synced_at', { mode: 'timestamp' }).notNull(), |
| 80 | +}); |
| 81 | + |
| 82 | +export const projects = sqliteTable('projects', { |
| 83 | + id: integer('id').primaryKey({ autoIncrement: true }), |
| 84 | + external_id: text('external_id').notNull().unique(), |
| 85 | + name: text('name').notNull(), |
| 86 | + description: text('description'), |
| 87 | + data: blob('data', { mode: 'json' }), |
| 88 | + synced_at: integer('synced_at', { mode: 'timestamp' }).notNull(), |
| 89 | +}); |
| 90 | + |
| 91 | +// Offline Outbox (For Progress Sync) |
| 92 | + |
| 93 | +export const outbox = sqliteTable('outbox', { |
| 94 | + id: integer('id').primaryKey({ autoIncrement: true }), |
| 95 | + type: text('type', { enum: ['quest_progress', 'hideout_module_progress', 'skill_node_progress', 'blueprint_progress'] }).notNull(), |
| 96 | + target_id: text('target_id').notNull(), // External ID of the entity |
| 97 | + action: text('action', { enum: ['upsert', 'delete'] }).notNull(), |
| 98 | + payload: blob('payload', { mode: 'json' }).notNull(), // The actual progress data |
| 99 | + created_at: integer('created_at', { mode: 'timestamp' }).notNull(), |
| 100 | + retry_count: integer('retry_count').default(0), |
| 101 | +}); |
0 commit comments