29 lines
719 B
JavaScript
29 lines
719 B
JavaScript
const sequelize = require('../config/database')
|
|
const Vaccine = require('../models/Vaccine')
|
|
|
|
async function createVaccineTable() {
|
|
try {
|
|
console.log('开始创建疫苗表...')
|
|
|
|
// 同步模型到数据库
|
|
await Vaccine.sync({ force: true })
|
|
console.log('疫苗表创建成功')
|
|
|
|
// 验证表是否创建成功
|
|
const tableExists = await sequelize.getQueryInterface().showAllTables()
|
|
console.log('数据库中的表:', tableExists)
|
|
|
|
} catch (error) {
|
|
console.error('创建疫苗表失败:', error)
|
|
} finally {
|
|
await sequelize.close()
|
|
}
|
|
}
|
|
|
|
// 如果直接运行此脚本
|
|
if (require.main === module) {
|
|
createVaccineTable()
|
|
}
|
|
|
|
module.exports = createVaccineTable
|