@axiosleo/orm-mysql 0.14.3 → 0.14.4

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/bin/orm-mysql.js CHANGED
@@ -9,7 +9,7 @@ const app = new App({
9
9
  name: 'MySQL ORM CLI',
10
10
  desc: 'migrate, model, seed, etc.',
11
11
  bin: 'orm-mysql',
12
- version: '0.14.3',
12
+ version: '0.14.4',
13
13
  commands_dir: path.join(__dirname, '../commands'),
14
14
  });
15
15
 
package/index.d.ts CHANGED
@@ -708,6 +708,16 @@ export declare class MigrationInterface {
708
708
  * @param newTableName
709
709
  */
710
710
  renameTable(oldTableName: string, newTableName: string): void;
711
+
712
+ /**
713
+ * change column
714
+ * @param tableName
715
+ * @param columnName
716
+ * @param options
717
+ */
718
+ changeColumn(tableName: string, columnName: string, options: {
719
+ type: FieldType,
720
+ } & CreateColumnOptions): void;
711
721
  }
712
722
 
713
723
  export type MigrateAction = 'up' | 'down' | 'UP' | 'DOWN';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axiosleo/orm-mysql",
3
- "version": "0.14.3",
3
+ "version": "0.14.4",
4
4
  "description": "MySQL ORM tool",
5
5
  "keywords": [
6
6
  "mysql",
package/src/builder.js CHANGED
@@ -523,6 +523,18 @@ class ManageSQLBuilder extends Builder {
523
523
  }
524
524
  }
525
525
 
526
+ changeColumn(options) {
527
+ _validate(options, {
528
+ tableName: 'required|string',
529
+ columnName: 'required|string',
530
+ });
531
+ const columnOptions = {
532
+ ...options.options,
533
+ name: options.columnName,
534
+ };
535
+ return _render('ALTER TABLE `${tableName}` MODIFY COLUMN ' + this.renderSingleColumn(columnOptions), { tableName: options.tableName });
536
+ }
537
+
526
538
  renameTable(options) {
527
539
  _validate(options, {
528
540
  oldName: 'required|string',
package/src/migration.js CHANGED
@@ -337,6 +337,19 @@ function _initMigration(file, queries = {}) {
337
337
  }, ...baseAttr
338
338
  });
339
339
 
340
+ Object.defineProperty(migration, 'changeColumn', {
341
+ value: function (tableName, columnName, options) {
342
+ const builder = new ManageSQLBuilder({
343
+ operator: 'change',
344
+ target: 'column',
345
+ tableName,
346
+ columnName,
347
+ options
348
+ });
349
+ queries[file].push({ sql: builder.sql, values: builder.values });
350
+ }, ...baseAttr
351
+ });
352
+
340
353
  return migration;
341
354
  }
342
355