gg-mysql-connector 1.0.90 → 1.0.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -55,7 +55,7 @@ class MyDBMigrator {
|
|
|
55
55
|
async alterForeignKey(tableName, col) {
|
|
56
56
|
if (col.FOREIGN_KEY) {
|
|
57
57
|
for (const row of col.FOREIGN_KEY) {
|
|
58
|
-
const CONSTRAINT = `fk_${tableName}_${col.COLUMN_NAME}_${row.tableName}_${row.columnName}
|
|
58
|
+
const CONSTRAINT = `fk_${tableName}_${col.COLUMN_NAME}_${row.tableName}_${row.columnName}`.slice(0, 64);
|
|
59
59
|
const constraintExist = await this.isConstraintNameExist(CONSTRAINT);
|
|
60
60
|
if (constraintExist) {
|
|
61
61
|
await this.MyDB.query(`ALTER TABLE ${tableName} DROP FOREIGN KEY ${CONSTRAINT}`);
|
|
@@ -146,6 +146,12 @@ class MyDBMigrator {
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
async alterUniqueKey(tableName, columnName, IS_UNIQUE) {
|
|
149
|
+
if (IS_UNIQUE === true) {
|
|
150
|
+
// ต้องโหลดใหม่ เพราะ กรณี ที่เพิ่ม column ใหม่ที่เป็น unique index แล้ว โค้ดก่อนหน้าจะเพิ่ม column เข้าเข้าไม่ก่อน
|
|
151
|
+
// onetimeLoadColumnContent จะยังไม่มี ข้อมูล column ใหม่ ทำให้ไม่ยอม add unique key index ให้
|
|
152
|
+
this.onetimeLoadColumnContent = [];
|
|
153
|
+
await this.loadColumnContentIfEmpty();
|
|
154
|
+
}
|
|
149
155
|
const data = this.onetimeLoadColumnContent.find((row) => row.COLUMN_NAME === columnName && row.TABLE_NAME === tableName);
|
|
150
156
|
if (data) {
|
|
151
157
|
if ((data.COLUMN_KEY === "UNI" && !IS_UNIQUE) ||
|
package/package.json
CHANGED
|
@@ -89,7 +89,11 @@ export default class MyDBMigrator {
|
|
|
89
89
|
) {
|
|
90
90
|
if (col.FOREIGN_KEY) {
|
|
91
91
|
for (const row of col.FOREIGN_KEY) {
|
|
92
|
-
const CONSTRAINT =
|
|
92
|
+
const CONSTRAINT =
|
|
93
|
+
`fk_${tableName}_${col.COLUMN_NAME}_${row.tableName}_${row.columnName}`.slice(
|
|
94
|
+
0,
|
|
95
|
+
64
|
|
96
|
+
)
|
|
93
97
|
|
|
94
98
|
const constraintExist = await this.isConstraintNameExist(CONSTRAINT)
|
|
95
99
|
if (constraintExist) {
|
|
@@ -237,6 +241,12 @@ export default class MyDBMigrator {
|
|
|
237
241
|
columnName: string,
|
|
238
242
|
IS_UNIQUE: boolean | undefined
|
|
239
243
|
) {
|
|
244
|
+
if (IS_UNIQUE === true) {
|
|
245
|
+
// ต้องโหลดใหม่ เพราะ กรณี ที่เพิ่ม column ใหม่ที่เป็น unique index แล้ว โค้ดก่อนหน้าจะเพิ่ม column เข้าเข้าไม่ก่อน
|
|
246
|
+
// onetimeLoadColumnContent จะยังไม่มี ข้อมูล column ใหม่ ทำให้ไม่ยอม add unique key index ให้
|
|
247
|
+
this.onetimeLoadColumnContent = []
|
|
248
|
+
await this.loadColumnContentIfEmpty()
|
|
249
|
+
}
|
|
240
250
|
const data = this.onetimeLoadColumnContent.find(
|
|
241
251
|
(row) => row.COLUMN_NAME === columnName && row.TABLE_NAME === tableName
|
|
242
252
|
)
|