Express migration (#80)

* Initial migration

* Cleanup and create migration scripts

* Introduce test suite

* Fix test issues

* Correct CORS issue and update paths

* Update README
This commit is contained in:
Chris 2025-06-16 21:50:44 +03:00 committed by GitHub
parent 7a5fe2b11c
commit 3c1209a5a9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
167 changed files with 24985 additions and 9335 deletions

View file

@ -0,0 +1,39 @@
// Set test environment before importing models
process.env.NODE_ENV = 'test';
const { sequelize } = require('../../models');
beforeAll(async () => {
await sequelize.sync({ force: true });
}, 30000);
beforeEach(async () => {
// Clean all tables except Sessions to avoid conflicts
try {
const models = Object.values(sequelize.models);
const nonSessionModels = models.filter(model => model.name !== 'Session');
await Promise.all(nonSessionModels.map(model => model.destroy({ truncate: true, cascade: true })));
} catch (error) {
// Ignore errors during cleanup
}
});
afterEach(async () => {
// Clean up sessions after each test
try {
const Session = sequelize.models.Session;
if (Session) {
await Session.destroy({ truncate: true });
}
} catch (error) {
// Ignore errors during session cleanup
}
});
afterAll(async () => {
try {
await sequelize.close();
} catch (error) {
// Database may already be closed
}
}, 30000);