gg-mysql-connector 1.0.55 → 1.0.59

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.
@@ -32,6 +32,7 @@ export default class GGMySQLConnector<Main> implements ClassDBInterface<Main> {
32
32
  COLUMN_NAME: string;
33
33
  TABLE_NAME: string;
34
34
  DATA_TYPE: string;
35
+ COLUMN_TYPE: string;
35
36
  }[] | null;
36
37
  isConnected: boolean;
37
38
  constructor(DBInfo: DatabaseConfigInterface);
@@ -228,7 +228,7 @@ class GGMySQLConnector {
228
228
  await this.loadColumnListToCache();
229
229
  }
230
230
  async loadColumnListToCache() {
231
- const result = (await this.query(`SELECT COLUMN_NAME,TABLE_NAME,DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '${this.DBInfo.database}'`, undefined, false));
231
+ const result = (await this.query(`SELECT COLUMN_NAME,TABLE_NAME,DATA_TYPE,COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '${this.DBInfo.database}'`, undefined, false));
232
232
  this.columnAndTableListCache = result;
233
233
  }
234
234
  async getColumnList(tableName) {
@@ -8,6 +8,7 @@ export default class MyDBMigrator {
8
8
  TABLE_NAME: string;
9
9
  COLUMN_DEFAULT: string;
10
10
  COLUMN_KEY: string;
11
+ COLUMN_TYPE: string;
11
12
  }[];
12
13
  constructor(connection: ModelGenerator);
13
14
  migrateTable(model: MyModel[]): Promise<void>;
@@ -119,12 +119,10 @@ class MyDBMigrator {
119
119
  const data = this.onetimeLoadColumnContent.find((row) => row.COLUMN_NAME === columnName && row.TABLE_NAME === tableName);
120
120
  if (data) {
121
121
  let possibleValueString = possibleValue
122
- .map((row) => {
123
- return `"${row}"`;
124
- })
122
+ .map((row) => `"${row}"`)
125
123
  .join(", ");
126
124
  try {
127
- await this.MyDB.query(`ALTER TABLE ${tableName} MODIFY COLUMN ${columnName} ENUM(${possibleValueString}) NOT NULL;`);
125
+ await this.MyDB.query(`ALTER TABLE ${tableName} MODIFY COLUMN ${columnName} ENUM(${possibleValueString}) ;`);
128
126
  }
129
127
  catch (e) {
130
128
  const data = await this.MyDB.query(`SELECT DISTINCT(${columnName}) as columnValue FROM ${tableName}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gg-mysql-connector",
3
- "version": "1.0.55",
3
+ "version": "1.0.59",
4
4
  "description": "",
5
5
  "main": "dist/src/index.js",
6
6
  "scripts": {
@@ -57,7 +57,12 @@ export default class GGMySQLConnector<Main> implements ClassDBInterface<Main> {
57
57
  isPrintStatement: boolean
58
58
  tableAndViewNameList: string[]
59
59
  columnAndTableListCache:
60
- | { COLUMN_NAME: string; TABLE_NAME: string; DATA_TYPE: string }[]
60
+ | {
61
+ COLUMN_NAME: string
62
+ TABLE_NAME: string
63
+ DATA_TYPE: string
64
+ COLUMN_TYPE: string
65
+ }[]
61
66
  | null
62
67
  isConnected: boolean
63
68
 
@@ -374,11 +379,17 @@ export default class GGMySQLConnector<Main> implements ClassDBInterface<Main> {
374
379
  COLUMN_NAME: string
375
380
  TABLE_NAME: string
376
381
  DATA_TYPE: string
382
+ COLUMN_TYPE: string
377
383
  }[] = (await this.query(
378
- `SELECT COLUMN_NAME,TABLE_NAME,DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '${this.DBInfo.database}'`,
384
+ `SELECT COLUMN_NAME,TABLE_NAME,DATA_TYPE,COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '${this.DBInfo.database}'`,
379
385
  undefined,
380
386
  false
381
- )) as { COLUMN_NAME: string; TABLE_NAME: string; DATA_TYPE: string }[]
387
+ )) as {
388
+ COLUMN_NAME: string
389
+ TABLE_NAME: string
390
+ DATA_TYPE: string
391
+ COLUMN_TYPE: string
392
+ }[]
382
393
 
383
394
  this.columnAndTableListCache = result
384
395
  }
@@ -12,6 +12,7 @@ export default class MyDBMigrator {
12
12
  TABLE_NAME: string
13
13
  COLUMN_DEFAULT: string
14
14
  COLUMN_KEY: string
15
+ COLUMN_TYPE: string
15
16
  }[]
16
17
  constructor(connection: ModelGenerator) {
17
18
  this.MyDB = connection
@@ -197,14 +198,12 @@ export default class MyDBMigrator {
197
198
  )
198
199
  if (data) {
199
200
  let possibleValueString = possibleValue
200
- .map((row) => {
201
- return `"${row}"`
202
- })
201
+ .map((row) => `"${row}"`)
203
202
  .join(", ")
204
203
 
205
204
  try {
206
205
  await this.MyDB.query(
207
- `ALTER TABLE ${tableName} MODIFY COLUMN ${columnName} ENUM(${possibleValueString}) NOT NULL;`
206
+ `ALTER TABLE ${tableName} MODIFY COLUMN ${columnName} ENUM(${possibleValueString}) ;`
208
207
  )
209
208
  } catch (e) {
210
209
  const data: { columnValue: any }[] = await this.MyDB.query(