Ошибка синхронизации с бд (sequelize)
Не могу понять почему не создалась таблица по описанию модели в конструкторе c помощью метода sync(). Код:
import { BasicRepository } from "../domain_service/BasicRepository.js";
import {Sequelize } from "sequelize";
export class ContactRepository extends BasicRepository{
сontactModel;
sequelize;
constructor(connectionString){
super();
this._connectionString = connectionString;
this.sequelize = new Sequelize(this._connectionString);
this.сontactModel = this.sequelize.define('contact',
{
id: {
type: Sequelize.INTEGER,
autoIncrement: true,
primaryKey: true,
allowNull: false
},
firstName: {
type: Sequelize.TEXT
},
lastName: {
type: Sequelize.TEXT
},
email: {
type: Sequelize.TEXT,
unique: true
}
}
);
this.sequelize.sync().then(result=>{
console.log(result);
})
.catch(err=> console.log(err));
}
getAll(){
return this.сontactModel.findAll({raw:true});
}
create(contact){
this.сontactModel.create({firstName: contact.firstName,
lastName: contact.lastName,
email: contact.email}).then(res=>{
const newContact = {id: res.id,
firstName: res.firstName,
lastName: res.lastName,
email: res.email}
console.log(newContact);
}).catch(err=>console.log(err));
};
update(contact){
this.сontactModel.update({
firstName: contact.firstName,
lastName: contact.lastName,
email: contact.email
},
{where: {
id: contact.id
}
}).then((res) => {
console.log(res);
});
};
delete(id){
this.сontactModel.destroy({
where: {
id: id
}
}).then((res) => {
console.log(res);
});
}
}
Ошибка:
parent: [Error: SQLITE_ERROR: no such table: contacts] {
errno: 1,
code: 'SQLITE_ERROR',
sql: 'SELECT `id`, `firstName`, `lastName`, `email`, `createdAt`, `updatedAt` FROM `contacts` AS `contact`;'
},