gg-mysql-connector 1.0.102 → 1.0.103
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.
- package/app_INF.ts +5 -0
- package/app_model_const.ts +5 -1
- package/dist/app_INF.d.ts +6 -0
- package/dist/app_model_const.d.ts +6 -0
- package/dist/app_model_const.js +5 -0
- package/dist/src/MyDBMigrator/MyDBMigrator.d.ts +1 -0
- package/dist/src/MyDBMigrator/MyDBMigrator.js +12 -0
- package/package.json +1 -1
- package/src/MyDBMigrator/MyDBMigrator.ts +18 -0
package/app_INF.ts
CHANGED
package/app_model_const.ts
CHANGED
|
@@ -5,7 +5,11 @@
|
|
|
5
5
|
price: "number",
|
|
6
6
|
description: "string",
|
|
7
7
|
amount: "number",
|
|
8
|
-
userId: "number", },
|
|
8
|
+
userId: "number", }, item__stock : {
|
|
9
|
+
id: "number",
|
|
10
|
+
userId: "number",
|
|
11
|
+
itemId: "number",
|
|
12
|
+
amount: "number", }, user : {
|
|
9
13
|
id: "number",
|
|
10
14
|
name: "string", }, item__each_user : {
|
|
11
15
|
id: "number",
|
package/dist/app_INF.d.ts
CHANGED
|
@@ -7,6 +7,12 @@ export declare const app_model_const: {
|
|
|
7
7
|
readonly amount: "number";
|
|
8
8
|
readonly userId: "number";
|
|
9
9
|
};
|
|
10
|
+
readonly item__stock: {
|
|
11
|
+
readonly id: "number";
|
|
12
|
+
readonly userId: "number";
|
|
13
|
+
readonly itemId: "number";
|
|
14
|
+
readonly amount: "number";
|
|
15
|
+
};
|
|
10
16
|
readonly user: {
|
|
11
17
|
readonly id: "number";
|
|
12
18
|
readonly name: "string";
|
package/dist/app_model_const.js
CHANGED
|
@@ -26,6 +26,7 @@ export default class MyDBMigrator {
|
|
|
26
26
|
private checkIsColumnDataTypeChange;
|
|
27
27
|
private alterUniqueKey;
|
|
28
28
|
private alterIndex;
|
|
29
|
+
private deleteOldIndexVersion;
|
|
29
30
|
private alterPossibleEnum;
|
|
30
31
|
migrateView_v2(viewModel: MyViewModel[]): Promise<void>;
|
|
31
32
|
private checkIsPrimaryKey;
|
|
@@ -26,6 +26,8 @@ class MyDBMigrator {
|
|
|
26
26
|
await this.alterDataType(row.tableName, col);
|
|
27
27
|
await this.alterUniqueKey(row.tableName, col.COLUMN_NAME, col.IS_UNIQUE);
|
|
28
28
|
await this.alterIndex(row.tableName, col.COLUMN_NAME, col.IS_INDEX);
|
|
29
|
+
//!! delete this next version. need to execute only 1 time on production
|
|
30
|
+
await this.deleteOldIndexVersion(row.tableName, col.COLUMN_NAME);
|
|
29
31
|
await this.alterPossibleEnum(row.tableName, col.COLUMN_NAME, col.POSSIBLE_VALUE, col.IS_NOT_NULL);
|
|
30
32
|
await this.alterForeignKey(row.tableName, col);
|
|
31
33
|
}
|
|
@@ -196,6 +198,16 @@ class MyDBMigrator {
|
|
|
196
198
|
else if (isIndex === false && isFound === true)
|
|
197
199
|
await this.MyDB.query(`DROP INDEX ${indexIndexName} ON ${tableName};`);
|
|
198
200
|
}
|
|
201
|
+
async deleteOldIndexVersion(tableName, columnName) {
|
|
202
|
+
console.log("deleteOldIndexVersion()");
|
|
203
|
+
const indexIndexName = `${columnName}`;
|
|
204
|
+
const indexList = (await this.MyDB.query(`SHOW INDEX FROM ${tableName}`));
|
|
205
|
+
const isFound = indexList.find((iRow) => iRow.Key_name === indexIndexName)
|
|
206
|
+
? true
|
|
207
|
+
: false;
|
|
208
|
+
if (isFound === true)
|
|
209
|
+
await this.MyDB.query(`DROP INDEX ${indexIndexName} ON ${tableName};`);
|
|
210
|
+
}
|
|
199
211
|
async alterPossibleEnum(tableName, columnName, possibleValue, isNotNull) {
|
|
200
212
|
console.log("alterPossibleEnum()");
|
|
201
213
|
if (!possibleValue)
|
package/package.json
CHANGED
|
@@ -41,6 +41,9 @@ export default class MyDBMigrator {
|
|
|
41
41
|
await this.alterDataType(row.tableName, col)
|
|
42
42
|
await this.alterUniqueKey(row.tableName, col.COLUMN_NAME, col.IS_UNIQUE)
|
|
43
43
|
await this.alterIndex(row.tableName, col.COLUMN_NAME, col.IS_INDEX)
|
|
44
|
+
//!! delete this next version. need to execute only 1 time on production
|
|
45
|
+
await this.deleteOldIndexVersion(row.tableName, col.COLUMN_NAME)
|
|
46
|
+
|
|
44
47
|
await this.alterPossibleEnum(
|
|
45
48
|
row.tableName,
|
|
46
49
|
col.COLUMN_NAME,
|
|
@@ -300,6 +303,21 @@ export default class MyDBMigrator {
|
|
|
300
303
|
await this.MyDB.query(`DROP INDEX ${indexIndexName} ON ${tableName};`)
|
|
301
304
|
}
|
|
302
305
|
|
|
306
|
+
private async deleteOldIndexVersion(tableName: string, columnName: string) {
|
|
307
|
+
console.log("deleteOldIndexVersion()")
|
|
308
|
+
|
|
309
|
+
const indexIndexName = `${columnName}`
|
|
310
|
+
const indexList = (await this.MyDB.query(
|
|
311
|
+
`SHOW INDEX FROM ${tableName}`
|
|
312
|
+
)) as { Key_name: string }[]
|
|
313
|
+
const isFound = indexList.find((iRow) => iRow.Key_name === indexIndexName)
|
|
314
|
+
? true
|
|
315
|
+
: false
|
|
316
|
+
|
|
317
|
+
if (isFound === true)
|
|
318
|
+
await this.MyDB.query(`DROP INDEX ${indexIndexName} ON ${tableName};`)
|
|
319
|
+
}
|
|
320
|
+
|
|
303
321
|
private async alterPossibleEnum(
|
|
304
322
|
tableName: string,
|
|
305
323
|
columnName: string,
|