fix create-db bug causing by Interface.ts cache

pull/275/head
Bosn 7 years ago
parent b781393520
commit 2ae02a800f

@ -22,7 +22,7 @@ export default class Interface extends Model<Interface> {
@BeforeBulkUpdate @BeforeBulkUpdate
@BeforeBulkDelete @BeforeBulkDelete
static async bulkDeleteCache(options: any) { static async bulkDeleteCache(options: any) {
let id: number = options && options.attributes && options.attributes.id let id: number = +(options && options.attributes && options.attributes.id)
if (!id) { if (!id) {
id = options.where && +options.where.id id = options.where && +options.where.id
} }
@ -32,7 +32,8 @@ export default class Interface extends Model<Interface> {
id = arr[1].id id = arr[1].id
} }
} }
if (id) { if (+id) {
id = +id
const itf = await Interface.findById(id) const itf = await Interface.findById(id)
await RedisService.delCache(CACHE_KEY.REPOSITORY_GET, itf.repositoryId) await RedisService.delCache(CACHE_KEY.REPOSITORY_GET, itf.repositoryId)
} }

@ -1,5 +1,5 @@
import sequelize from '../../models/sequelize' import sequelize from '../../models/sequelize'
import { User, Organization, Repository, Module, Interface, Property } from '../../models/index' import { User, Organization, Repository, Module, Interface, Property, Room } from '../../models/index'
import { BO_ADMIN, BO_MOZHI } from './bo' import { BO_ADMIN, BO_MOZHI } from './bo'
import { BO_USER_FN, BO_ORGANIZATION_FN, BO_REPOSITORY_FN, BO_MODULE_FN, BO_INTERFACE_FN, BO_PROPERTY_FN } from './bo' import { BO_USER_FN, BO_ORGANIZATION_FN, BO_REPOSITORY_FN, BO_MODULE_FN, BO_INTERFACE_FN, BO_PROPERTY_FN } from './bo'
import { BO_USER_COUNT, BO_ORGANIZATION_COUNT, BO_REPOSITORY_COUNT, BO_MODULE_COUNT, BO_INTERFACE_COUNT, BO_PROPERTY_COUNT } from './bo' import { BO_USER_COUNT, BO_ORGANIZATION_COUNT, BO_REPOSITORY_COUNT, BO_MODULE_COUNT, BO_INTERFACE_COUNT, BO_PROPERTY_COUNT } from './bo'
@ -12,6 +12,7 @@ export async function init () {
force: true, force: true,
logging: console.log, logging: console.log,
}) })
await Room.destroy(EMPTY_WHERE)
await User.destroy(EMPTY_WHERE) await User.destroy(EMPTY_WHERE)
await Organization.destroy(EMPTY_WHERE) await Organization.destroy(EMPTY_WHERE)
await Repository.destroy(EMPTY_WHERE) await Repository.destroy(EMPTY_WHERE)
@ -19,6 +20,7 @@ export async function init () {
await Interface.destroy(EMPTY_WHERE) await Interface.destroy(EMPTY_WHERE)
await Property.destroy(EMPTY_WHERE) await Property.destroy(EMPTY_WHERE)
// 用户 // 用户
await User.create(BO_ADMIN) await User.create(BO_ADMIN)
await User.create(BO_MOZHI) await User.create(BO_MOZHI)

@ -89,11 +89,11 @@ export default class MigrateService {
return true return true
} }
public static checkAndFix(): void { public static checkAndFix(): void {
console.log('checkAndFix') // console.log('checkAndFix')
this.checkPasswordMd5().then() // this.checkPasswordMd5().then()
} }
public static async checkPasswordMd5() { static async checkPasswordMd5() {
console.log(' checkPasswordMd5') console.log(' checkPasswordMd5')
const users = await User.findAll() const users = await User.findAll()
if (users.length === 0 || isMd5(users[0].password)) { if (users.length === 0 || isMd5(users[0].password)) {

Loading…
Cancel
Save