@nocobase/plugin-users 0.19.0-alpha.3 → 0.19.0-alpha.5

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.
@@ -1,7 +1,7 @@
1
1
  module.exports = {
2
- "@nocobase/client": "0.19.0-alpha.3",
3
- "@nocobase/database": "0.19.0-alpha.3",
4
- "@nocobase/server": "0.19.0-alpha.3",
5
- "@nocobase/utils": "0.19.0-alpha.3",
6
- "@nocobase/actions": "0.19.0-alpha.3"
2
+ "@nocobase/client": "0.19.0-alpha.5",
3
+ "@nocobase/database": "0.19.0-alpha.5",
4
+ "@nocobase/server": "0.19.0-alpha.5",
5
+ "@nocobase/utils": "0.19.0-alpha.5",
6
+ "@nocobase/actions": "0.19.0-alpha.5"
7
7
  };
@@ -31,20 +31,25 @@ class AddUsersPhoneMigration extends import_server.Migration {
31
31
  fields: [
32
32
  {
33
33
  type: "string",
34
- name: "phone",
35
- unique: true
34
+ name: "phone"
36
35
  }
37
36
  ]
38
37
  });
39
38
  const tableNameWithSchema = collection.getTableNameWithSchema();
40
- const field = collection.getField("username");
41
- await this.db.sequelize.getQueryInterface().addColumn(tableNameWithSchema, field.columnName(), {
42
- type: import_database.DataTypes.STRING
43
- });
44
- await this.db.sequelize.getQueryInterface().addConstraint(tableNameWithSchema, {
45
- type: "unique",
46
- fields: [field.columnName()]
47
- });
39
+ const field = collection.getField("phone");
40
+ const exists = await field.existsInDb();
41
+ if (!exists) {
42
+ await this.db.sequelize.getQueryInterface().addColumn(tableNameWithSchema, field.columnName(), {
43
+ type: import_database.DataTypes.STRING
44
+ });
45
+ }
46
+ try {
47
+ await this.db.sequelize.getQueryInterface().addConstraint(tableNameWithSchema, {
48
+ type: "unique",
49
+ fields: [field.columnName()]
50
+ });
51
+ } catch (error) {
52
+ }
48
53
  this.db.removeCollection("users");
49
54
  }
50
55
  async down() {
@@ -31,20 +31,25 @@ class AddUserNameMigration extends import_server.Migration {
31
31
  fields: [
32
32
  {
33
33
  type: "string",
34
- name: "username",
35
- unique: true
34
+ name: "username"
36
35
  }
37
36
  ]
38
37
  });
39
38
  const tableNameWithSchema = collection.getTableNameWithSchema();
40
39
  const field = collection.getField("username");
41
- await this.db.sequelize.getQueryInterface().addColumn(tableNameWithSchema, field.columnName(), {
42
- type: import_database.DataTypes.STRING
43
- });
44
- await this.db.sequelize.getQueryInterface().addConstraint(tableNameWithSchema, {
45
- type: "unique",
46
- fields: [field.columnName()]
47
- });
40
+ const exists = await field.existsInDb();
41
+ if (!exists) {
42
+ await this.db.sequelize.getQueryInterface().addColumn(tableNameWithSchema, field.columnName(), {
43
+ type: import_database.DataTypes.STRING
44
+ });
45
+ }
46
+ try {
47
+ await this.db.sequelize.getQueryInterface().addConstraint(tableNameWithSchema, {
48
+ type: "unique",
49
+ fields: [field.columnName()]
50
+ });
51
+ } catch (error) {
52
+ }
48
53
  this.db.removeCollection("users");
49
54
  }
50
55
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "用户",
5
5
  "description": "Provides a basic user model and a password-based user authentication type, and extended the createdBy and updatedBy field types",
6
6
  "description.zh-CN": "提供了基础的用户模型和基于密码的用户认证方式,并拓展了创建人和最后更新人字段类型",
7
- "version": "0.19.0-alpha.3",
7
+ "version": "0.19.0-alpha.5",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "devDependencies": {
@@ -22,5 +22,5 @@
22
22
  "@nocobase/test": "0.x",
23
23
  "@nocobase/utils": "0.x"
24
24
  },
25
- "gitHead": "3cee597df101a3f8f0f1e2a6f75fc2dddd02ac74"
25
+ "gitHead": "580eca25451ec731d17ddef285d0b8c52c48d501"
26
26
  }