Migrate all the things
* Migrates from Mongo to Postgres. * Migrates from JSPM to Webpack. * Migrates from React to Vuejs. * Migrates from Bootstrap to Bulma. Also: * Fixes rendering of meta data in the document head tag.
This commit is contained in:
parent
09706778d9
commit
7bb0497ff4
76 changed files with 6741 additions and 1760 deletions
35
models/index.js
Normal file
35
models/index.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import Sequelize from 'sequelize';
|
||||
|
||||
import debugname from 'debug';
|
||||
|
||||
const debug = debugname('match.audio:models');
|
||||
|
||||
const config = {
|
||||
dialect: 'postgres',
|
||||
protocol: 'postgres',
|
||||
logging: debug,
|
||||
};
|
||||
|
||||
const sequelize = new Sequelize(process.env.DATABASE_URL, config);
|
||||
const db = {};
|
||||
|
||||
fs
|
||||
.readdirSync(__dirname)
|
||||
.filter(file => (file.indexOf('.') !== 0) && (file !== 'index.js'))
|
||||
.forEach((file) => {
|
||||
const model = sequelize.import(path.join(__dirname, file));
|
||||
db[model.name] = model;
|
||||
});
|
||||
|
||||
Object.keys(db).forEach((modelName) => {
|
||||
if ('associate' in db[modelName]) {
|
||||
db[modelName].associate(db);
|
||||
}
|
||||
});
|
||||
|
||||
db.sequelize = sequelize;
|
||||
db.Sequelize = Sequelize;
|
||||
|
||||
export default db;
|
Loading…
Add table
Add a link
Reference in a new issue