mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 23:35:59 +00:00
create, drop sql object
This commit is contained in:
@@ -4,7 +4,7 @@ import {
|
||||
ColumnInfo,
|
||||
ConstraintInfo,
|
||||
DatabaseInfo,
|
||||
NamedObjectInfo,
|
||||
SqlObjectInfo,
|
||||
SqlDialect,
|
||||
TableInfo,
|
||||
} from '../../types';
|
||||
@@ -21,6 +21,16 @@ interface AlterOperation_DropTable {
|
||||
oldObject: TableInfo;
|
||||
}
|
||||
|
||||
interface AlterOperation_CreateSqlObject {
|
||||
operationType: 'createSqlObject';
|
||||
newObject: SqlObjectInfo;
|
||||
}
|
||||
|
||||
interface AlterOperation_DropSqlObject {
|
||||
operationType: 'dropSqlObject';
|
||||
oldObject: SqlObjectInfo;
|
||||
}
|
||||
|
||||
interface AlterOperation_RenameTable {
|
||||
operationType: 'renameTable';
|
||||
object: TableInfo;
|
||||
@@ -88,6 +98,8 @@ type AlterOperation =
|
||||
| AlterOperation_RenameTable
|
||||
| AlterOperation_RenameColumn
|
||||
| AlterOperation_RenameConstraint
|
||||
| AlterOperation_CreateSqlObject
|
||||
| AlterOperation_DropSqlObject
|
||||
| AlterOperation_RecreateTable;
|
||||
|
||||
export class AlterPlan {
|
||||
@@ -108,6 +120,20 @@ export class AlterPlan {
|
||||
});
|
||||
}
|
||||
|
||||
createSqlObject(obj: SqlObjectInfo) {
|
||||
this.operations.push({
|
||||
operationType: 'createSqlObject',
|
||||
newObject: obj,
|
||||
});
|
||||
}
|
||||
|
||||
dropSqlObject(obj: SqlObjectInfo) {
|
||||
this.operations.push({
|
||||
operationType: 'dropSqlObject',
|
||||
oldObject: obj,
|
||||
});
|
||||
}
|
||||
|
||||
createColumn(column: ColumnInfo) {
|
||||
this.operations.push({
|
||||
operationType: 'createColumn',
|
||||
@@ -419,6 +445,12 @@ export function runAlterOperation(op: AlterOperation, processor: AlterProcessor)
|
||||
case 'renameConstraint':
|
||||
processor.renameConstraint(op.object, op.newName);
|
||||
break;
|
||||
case 'createSqlObject':
|
||||
processor.createSqlObject(op.newObject);
|
||||
break;
|
||||
case 'dropSqlObject':
|
||||
processor.dropSqlObject(op.oldObject);
|
||||
break;
|
||||
case 'recreateTable':
|
||||
{
|
||||
const newTable = _.cloneDeep(op.table);
|
||||
|
||||
Reference in New Issue
Block a user