bug fix
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
jusax23 2023-03-28 18:28:52 +02:00
parent 23ebf3c75a
commit 0a1cb7c85f
Signed by: jusax23
GPG key ID: 499E2AA870C1CD41

View file

@ -121,7 +121,7 @@ export class Handler {
return found == fromAttrs.length && found == toAttrs.length;
}
function freeForUpdate(attr: string, table: string, start = false) {
function freeForUpdate(attr: string, table: string, start = false, pool = del) {
for (let i = 0; i < key.length; i++) {
const k = key[i];
if (
@ -130,7 +130,7 @@ export class Handler {
|| (start && (k.TABLE_NAME ?? k.table_name) == table
&& (k.COLUMN_NAME ?? k.column_name).toLowerCase() == attr.toLowerCase() && (k.REFERENCED_COLUMN_NAME ?? k.referenced_column_name) != null)
) {
del.appendEnding(handler.querys.removeForeignKey(handler, (k.TABLE_NAME ?? k.table_name), (k.CONSTRAINT_NAME ?? k.constraint_name)));
pool.appendEnding(handler.querys.removeForeignKey(handler, (k.TABLE_NAME ?? k.table_name), (k.CONSTRAINT_NAME ?? k.constraint_name)));
key.splice(i--, 1);
}
}
@ -195,7 +195,13 @@ export class Handler {
const a = table.dbLangTableAttributes[keys[j]];
const attrData = tableD[keys[j]];
if (attrData == null) {
create.appendEnding(handler.querys.addColumn(handler, a));
if (a.ops.autoIncrement) {
a.ops.autoIncrement = false;
create.appendEnding(handler.querys.addColumn(handler, a));
a.ops.autoIncrement = true;
connst.appendEnding(handler.querys.addColumn(handler, a));
}
else create.appendEnding(handler.querys.addColumn(handler, a));
if (a.ops.primaryKey) changePrimary = true;
} else if (
!handler.builders.compareDatatypes(handler, a.type, attrData.Type) ||
@ -203,10 +209,6 @@ export class Handler {
(!!a.ops.notNull || !!a.ops.autoIncrement || !!a.ops.primaryKey) != (attrData.Null == "NO") ||
(!!a.ops.autoIncrement) != (attrData.Extra == "auto_increment")
) {
/*console.log(!handler.builders.compareDatatypes(handler, a.type, attrData.Type), "|",
a.ops.default, attrData.Default, "|",
(!!a.ops.notNull || !!a.ops.autoIncrement || !!a.ops.primaryKey), (attrData.Null == "NO"), "|",
(!!a.ops.autoIncrement), (attrData.Extra == "auto_increment"));*/
freeForUpdate(a.name, a.table.dbLangTableName);
if (a.ops.autoIncrement) {
a.ops.autoIncrement = false;
@ -231,6 +233,7 @@ export class Handler {
a.ops.autoIncrement = true;
connst.appendEnding(handler.querys.changeColumn(handler, a));
}
freeForUpdate(a.name, a.table.dbLangTableName, true, create);
}
}
if (changePrimary) {
@ -257,7 +260,7 @@ export class Handler {
}
if (!create.isEmpty()) del.append(create);
if (!connst.isEmpty()) del.append(connst);
if (!del.isEmpty()) await db.query(handler.builders.query(del));
if (!del.isEmpty()) await db.query(handler.builders.query(del), true);
}
querys = {