postgre, mysql uniques, recreate table WIP, drop index works

This commit is contained in:
Jan Prochazka
2021-09-04 18:43:59 +02:00
parent b3b7d021c5
commit 04a6540890
15 changed files with 113 additions and 27 deletions

View File

@@ -420,8 +420,24 @@ export class SqlDumper implements AlterProcessor {
);
}
dropIndex(ix: IndexInfo) {}
createIndex(ix: IndexInfo) {}
dropIndex(ix: IndexInfo) {
this.put('^drop ^index %i', ix.constraintName);
if (this.dialect.dropIndexContainsTableSpec) {
this.put(' ^on %f', ix);
}
this.endCommand();
}
createIndex(ix: IndexInfo) {
this.put('^create');
if (ix.indexType) this.put(' %k', ix.indexType);
if (ix.isUnique) this.put(' ^unique');
this.put(' ^index %i &n^on %f (&>&n', ix.constraintName, ix);
this.putCollection(',&n', ix.columns, col => {
this.put('%i %k', col.columnName, col.isDescending == true ? 'DESC' : 'ASC');
});
this.put('&<&n)');
this.endCommand();
}
dropUnique(uq: UniqueInfo) {
this.dropConstraintCore(uq);

View File

@@ -207,6 +207,8 @@ export class AlterPlan {
...(this.dialect.dropColumnDependencies?.includes('uniques') ? table.uniques : []),
]).filter(cnt => cnt.columns.find(col => col.columnName == op.oldObject.columnName));
console.log('deletedConstraints', deletedConstraints);
const res: AlterOperation[] = [
...[...deletedFks, ...deletedConstraints].map(oldObject => {
const opRes: AlterOperation = {
@@ -260,11 +262,13 @@ export class AlterPlan {
): AlterOperation[] | null {
if (op.operationType == operationType) {
if (_.isFunction(isAllowed)) {
if (!isAllowed(op[objectField])) return null;
if (isAllowed(op[objectField])) return null;
} else {
if (!isAllowed) return null;
if (isAllowed) return null;
}
// console.log('*****************RECREATED NEEDED', op, operationType, isAllowed);
// console.log(this.dialect);
const table = this.db.tables.find(
x => x.pureName == op[objectField].pureName && x.schemaName == op[objectField].schemaName
);