preloaded data works

This commit is contained in:
Jan Prochazka
2021-11-27 17:49:02 +01:00
parent d4f4211ee4
commit 40d53275e3
12 changed files with 177 additions and 5 deletions

View File

@@ -8,6 +8,7 @@ import {
SqlObjectInfo,
SqlDialect,
TableInfo,
NamedObjectInfo,
} from '../../types';
import { DatabaseInfoAlterProcessor } from './database-info-alter-processor';
import { DatabaseAnalyser } from './DatabaseAnalyser';
@@ -86,6 +87,13 @@ interface AlterOperation_RecreateTable {
table: TableInfo;
operations: AlterOperation[];
}
interface AlterOperation_FillPreloadedRows {
operationType: 'fillPreloadedRows';
table: NamedObjectInfo;
oldRows: any[];
newRows: any[];
key: string[];
}
type AlterOperation =
| AlterOperation_CreateColumn
@@ -101,7 +109,8 @@ type AlterOperation =
| AlterOperation_RenameConstraint
| AlterOperation_CreateSqlObject
| AlterOperation_DropSqlObject
| AlterOperation_RecreateTable;
| AlterOperation_RecreateTable
| AlterOperation_FillPreloadedRows;
export class AlterPlan {
recreates = {
@@ -223,6 +232,16 @@ export class AlterPlan {
this.recreates.tables += 1;
}
fillPreloadedRows(table: NamedObjectInfo, oldRows: any[], newRows: any[], key: string[]) {
this.operations.push({
operationType: 'fillPreloadedRows',
table,
oldRows,
newRows,
key,
});
}
run(processor: AlterProcessor) {
for (const op of this.operations) {
runAlterOperation(op, processor);
@@ -545,6 +564,9 @@ export function runAlterOperation(op: AlterOperation, processor: AlterProcessor)
case 'dropSqlObject':
processor.dropSqlObject(op.oldObject);
break;
case 'fillPreloadedRows':
processor.fillPreloadedRows(op.table, op.oldRows, op.newRows, op.key);
break;
case 'recreateTable':
{
const oldTable = generateTablePairingId(op.table);