| 22 | } |
| 23 | |
| 24 | class MemoryMigrationAdapter implements DatabaseAdapter { |
| 25 | dialect = 'memory' |
| 26 | capabilities = { |
| 27 | returning: true, |
| 28 | savepoints: true, |
| 29 | upsert: true, |
| 30 | transactionalDdl: true, |
| 31 | migrationLock: true, |
| 32 | } |
| 33 | journalTableCreated = false |
| 34 | journalTableName = 'data_table_migrations' |
| 35 | journalRows: JournalRow[] = [] |
| 36 | executedScripts: Array<{ sql: string; transaction?: string }> = [] |
| 37 | scriptError: Error | undefined |
| 38 | lockAcquireCount = 0 |
| 39 | lockReleaseCount = 0 |
| 40 | beginTransactionCount = 0 |
| 41 | commitTransactionCount = 0 |
| 42 | rollbackTransactionCount = 0 |
| 43 | #transactionCounter = 0 |
| 44 | #tokens = new Set<string>() |
| 45 | |
| 46 | compileSql() { |
| 47 | return [{ text: '', values: [] }] |
| 48 | } |
| 49 | |
| 50 | async execute(request: DataManipulationRequest): Promise<DataManipulationResult> { |
| 51 | if (request.transaction) { |
| 52 | this.#assertToken(request.transaction) |
| 53 | } |
| 54 | |
| 55 | if (request.operation.kind !== 'raw') { |
| 56 | throw new Error('MemoryMigrationAdapter only supports raw execute operations') |
| 57 | } |
| 58 | |
| 59 | let statement = request.operation.sql |
| 60 | let text = statement.text.toLowerCase() |
| 61 | |
| 62 | if (text.startsWith('select 1 from ')) { |
| 63 | if (!this.journalTableCreated) { |
| 64 | throw new Error('Journal table does not exist') |
| 65 | } |
| 66 | |
| 67 | return { rows: [] } |
| 68 | } |
| 69 | |
| 70 | if (text.includes('select id, name, checksum, batch, applied_at from ')) { |
| 71 | if (!this.journalTableCreated) { |
| 72 | throw new Error('Journal table does not exist') |
| 73 | } |
| 74 | |
| 75 | return { |
| 76 | rows: this.journalRows.map((row) => ({ |
| 77 | id: row.id, |
| 78 | name: row.name, |
| 79 | checksum: row.checksum, |
| 80 | batch: row.batch, |
| 81 | applied_at: row.applied_at, |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…