Comments (3)
Well, actually i'm planning to have tests agains sqlite too :)
One reason for using PostgreSQL is that it has schemas, which is not available in other DBs. So to have tests against migrating and creating schemas — we use PostgreSQL
from sails-hook-sequelize.
I see. I can explain how do I do that with mysql. Hopefully it will help you implementing it.
I have a db/migrations/1234567890-init-models.js
file to init all database tables from models:
var glob = require('glob');
var path = require('path');
var models = {};
glob.sync('./api/models/*.js').forEach(function(file) {
var modelName = path.basename(file, '.js');
var model = require(path.resolve(file));
models[modelName] = model;
});
module.exports = {
up: function(queryInterface, Sequelize) {
var Project = queryInterface.sequelize;
for (var modelName in models) {
Project.define(modelName, models[modelName].attributes, models[modelName].options);
}
return Project.sync({force: true});
},
};
Then I have pretest
in package.json
like following sequelize db:drop; sequelize db:create; sequelize db:migrate
to init database.
Then before each test case I truncate all tables:
beforeEach(function(done) {
var models = Object.keys(sails.models).map(function(key) {
return sails.models[key];
});
var destroyPromises = models.map(function(model) {
return model.destroy({ truncate: true });
});
Promise.all(destroyPromises).then(function() {
done();
}).catch(done);
});
from sails-hook-sequelize.
I've added some tests against sqlite db. It was helpful to test some cases.
from sails-hook-sequelize.
Related Issues (20)
- option bug fix
- SequelizeUniqueConstraintError: Validation error HOT 3
- Sails lift hook load fail HOT 3
- model definitions as Sequelize-Auto HOT 1
- Error: Callback was already called HOT 1
- Table schema changes are not updating HOT 2
- sequelize not found in controller HOT 2
- SailsJS v1 - Using custom datastore HOT 1
- Sync is causing an error when I start sails for a second time HOT 9
- Model is not defined. HOT 2
- Model is not defined.
- Allow sharing of model definitions among datasources HOT 1
- Postgres Schema migration throws unique constraint violation errors when multiple datasources are defined HOT 1
- Blueprint APIs are not working after installing sails-hook-sequelize HOT 2
- Support Sequelize 5 HOT 4
- Sequelize should be a peerDependency HOT 4
- Problem if datastores > 1 HOT 1
- Document clsNamespace
- Support Sequelize 6 HOT 4
- Other fields not accessible for custom validations HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sails-hook-sequelize.