@axiosleo/orm-mysql 0.11.2 → 0.11.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.11.2',
12
+ version: '0.11.4',
13
13
  commands_dir: path.join(__dirname, '../commands'),
14
14
  });
15
15
 
@@ -9,7 +9,7 @@ class GenerateCommand extends Command {
9
9
  constructor() {
10
10
  super({
11
11
  name: 'generate',
12
- desc: '',
12
+ desc: 'Generate migration script file',
13
13
  alias: ['gen']
14
14
  });
15
15
  this.addArgument('name', 'Migration name', 'required', '');
package/index.d.ts CHANGED
@@ -437,7 +437,7 @@ interface ColumnItem {
437
437
  unsigned?: boolean,
438
438
  allowNull?: boolean,
439
439
  default?: string | number | boolean | null | 'timestamp',
440
- onUpdate?: boolean,
440
+ onUpdate?: string,
441
441
  comment?: string,
442
442
  autoIncrement?: boolean,
443
443
  primaryKey?: boolean,
@@ -490,7 +490,7 @@ export declare class MigrationInterface {
490
490
  unsigned?: boolean,
491
491
  allowNull?: boolean,
492
492
  default?: string | number | boolean | null | 'timestamp',
493
- onUpdate?: boolean,
493
+ onUpdate?: string,
494
494
  comment?: string,
495
495
  autoIncrement?: boolean,
496
496
  primaryKey?: boolean,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axiosleo/orm-mysql",
3
- "version": "0.11.2",
3
+ "version": "0.11.4",
4
4
  "description": "MySQL ORM tool",
5
5
  "keywords": [
6
6
  "mysql",
@@ -35,7 +35,7 @@
35
35
  "url": "https://github.com/AxiosLeo/node-orm-mysql"
36
36
  },
37
37
  "devDependencies": {
38
- "@types/node": "^20.11.26",
38
+ "@types/node": "^20.11.46",
39
39
  "chai": "^5.0.3",
40
40
  "eslint": "^8.56.0",
41
41
  "expect.js": "^0.3.1",
package/src/builder.js CHANGED
@@ -680,7 +680,7 @@ class ManageSQLBuilder extends Builder {
680
680
  } else if (type === 'TINYINT') {
681
681
  str += '(4)';
682
682
  }
683
- if (options.allowNull === false) {
683
+ if (options.allowNull === false || options.primaryKey === true) {
684
684
  str += ' NOT NULL';
685
685
  }
686
686
  if (options.unsigned === true) {
@@ -705,12 +705,12 @@ class ManageSQLBuilder extends Builder {
705
705
  if (options.onUpdate) {
706
706
  str += ` ON UPDATE ${options.onUpdate}`;
707
707
  }
708
- if (is.string(options.comment) && is.empty(options.comment) === false) {
709
- str += ` COMMENT '${options.comment}'`;
710
- }
711
708
  if (options.autoIncrement === true) {
712
709
  str += ' AUTO_INCREMENT';
713
710
  }
711
+ if (is.string(options.comment) && is.empty(options.comment) === false) {
712
+ str += ` COMMENT '${options.comment}'`;
713
+ }
714
714
  if (options.after) {
715
715
  str += ' AFTER `' + options.after + '`';
716
716
  }
package/src/migration.js CHANGED
@@ -52,7 +52,7 @@ async function init(context) {
52
52
  files = files.reverse();
53
53
  }
54
54
  context.files = files.filter(f => f !== '.connect.js');
55
-
55
+ context.config.dir = path.resolve(context.config.dir);
56
56
  const connectPath = path.join(context.config.dir, '.connect.js');
57
57
  if (await _exists(connectPath)) {
58
58
  const connect = require(connectPath);