mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 07:45:18 +00:00
fix: migration error
This commit is contained in:
parent
f466e6ec95
commit
c44f459756
@ -12,15 +12,17 @@ export default class AddUsersPhoneMigration extends Migration {
|
|||||||
{
|
{
|
||||||
type: 'string',
|
type: 'string',
|
||||||
name: 'phone',
|
name: 'phone',
|
||||||
unique: true,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
const tableNameWithSchema = collection.getTableNameWithSchema();
|
const tableNameWithSchema = collection.getTableNameWithSchema();
|
||||||
const field = collection.getField('username');
|
const field = collection.getField('phone');
|
||||||
await this.db.sequelize.getQueryInterface().addColumn(tableNameWithSchema, field.columnName(), {
|
const exists = await field.existsInDb();
|
||||||
type: DataTypes.STRING,
|
if (!exists) {
|
||||||
});
|
await this.db.sequelize.getQueryInterface().addColumn(tableNameWithSchema, field.columnName(), {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
});
|
||||||
|
}
|
||||||
await this.db.sequelize.getQueryInterface().addConstraint(tableNameWithSchema, {
|
await this.db.sequelize.getQueryInterface().addConstraint(tableNameWithSchema, {
|
||||||
type: 'unique',
|
type: 'unique',
|
||||||
fields: [field.columnName()],
|
fields: [field.columnName()],
|
||||||
|
@ -12,15 +12,17 @@ export default class AddUserNameMigration extends Migration {
|
|||||||
{
|
{
|
||||||
type: 'string',
|
type: 'string',
|
||||||
name: 'username',
|
name: 'username',
|
||||||
unique: true,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
const tableNameWithSchema = collection.getTableNameWithSchema();
|
const tableNameWithSchema = collection.getTableNameWithSchema();
|
||||||
const field = collection.getField('username');
|
const field = collection.getField('username');
|
||||||
await this.db.sequelize.getQueryInterface().addColumn(tableNameWithSchema, field.columnName(), {
|
const exists = await field.existsInDb();
|
||||||
type: DataTypes.STRING,
|
if (!exists) {
|
||||||
});
|
await this.db.sequelize.getQueryInterface().addColumn(tableNameWithSchema, field.columnName(), {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
});
|
||||||
|
}
|
||||||
await this.db.sequelize.getQueryInterface().addConstraint(tableNameWithSchema, {
|
await this.db.sequelize.getQueryInterface().addConstraint(tableNameWithSchema, {
|
||||||
type: 'unique',
|
type: 'unique',
|
||||||
fields: [field.columnName()],
|
fields: [field.columnName()],
|
||||||
|
Loading…
Reference in New Issue
Block a user