gg-mysql-connector 1.0.91 → 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.
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gg-mysql-connector",
3
- "version": "1.0.91",
3
+ "version": "1.0.92",
4
4
  "description": "",
5
5
  "main": "dist/src/index.js",
6
6
  "scripts": {
@@ -241,6 +241,12 @@ export default class MyDBMigrator {
241
241
  columnName: string,
242
242
  IS_UNIQUE: boolean | undefined
243
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
+ }
244
250
  const data = this.onetimeLoadColumnContent.find(
245
251
  (row) => row.COLUMN_NAME === columnName && row.TABLE_NAME === tableName
246
252
  )