<commit_before>const fs = require('fs');
const path = require('path');
const Sequelize = require('sequelize');

const basename = path.basename(__filename);
const env = process.env.NODE_ENV || 'test';
// eslint-disable-next-line import/no-dynamic-require
const config = require(`${__dirname}/../../config/config.json`)[env];
const db = {};

let sequelize;
if (config.use_env_variable) {
	sequelize = new Sequelize(process.env[config.use_env_variable], config);
} else {
	sequelize = new Sequelize(
		config.database,
		config.username,
		config.password,
		config,
	);
}

// eslint-disable-next-line import/no-dynamic-require
const PaperTrail = require(`${__dirname}/../../lib/index.js`).init(sequelize);
PaperTrail.defineModels();

fs.readdirSync(__dirname)
	.filter(
		file =>
			file.indexOf('.') !== 0 &&
			file !== basename &&
			file.slice(-3) === '.js',
	)
	.forEach(file => {
		const model = sequelize.import(path.join(__dirname, file));
		db[model.name] = model;
	});

fs.readdirSync(`${__dirname}/../migrations/`)
	.filter(
		file =>
			file.indexOf('.') !== 0 &&
			file !== basename &&
			file.slice(-3) === '.js',
	)
	.forEach(file => {
		// eslint-disable-next-line global-require, import/no-dynamic-require
		const migration = require(path.join(
			`${__dirname}/../migrations/`,
			file,
		));
		migration.up(sequelize.getQueryInterface(), Sequelize);
	});

Object.keys(db).forEach(modelName => {
	if (db[modelName].associate) {
		db[modelName].associate(db);
	}
});

db.sequelize = sequelize;
db.Sequelize = Sequelize;

module.exports = db;<commit_msg>sync sequelize before running tests<commit_after>const fs = require('fs');
const path = require('path');
const Sequelize = require('sequelize');

const basename = path.basename(__filename);
const env = process.env.NODE_ENV || 'test';
// eslint-disable-next-line import/no-dynamic-require
const config = require(`${__dirname}/../../config/config.json`)[env];
const db = {};

let sequelize;
if (config.use_env_variable) {
	sequelize = new Sequelize(process.env[config.use_env_variable], config);
} else {
	sequelize = new Sequelize(
		config.database,
		config.username,
		config.password,
		config,
	);
}

// eslint-disable-next-line import/no-dynamic-require
const PaperTrail = require(`${__dirname}/../../lib/index.js`).init(sequelize);
PaperTrail.defineModels();

fs.readdirSync(__dirname)
	.filter(
		file =>
			file.indexOf('.') !== 0 &&
			file !== basename &&
			file.slice(-3) === '.js',
	)
	.forEach(file => {
		const model = sequelize.import(path.join(__dirname, file));
		db[model.name] = model;
	});

fs.readdirSync(`${__dirname}/../migrations/`)
	.filter(
		file =>
			file.indexOf('.') !== 0 &&
			file !== basename &&
			file.slice(-3) === '.js',
	)
	.forEach(file => {
		// eslint-disable-next-line global-require, import/no-dynamic-require
		const migration = require(path.join(
			`${__dirname}/../migrations/`,
			file,
		));
		migration.up(sequelize.getQueryInterface(), Sequelize);
	});

Object.keys(db).forEach(modelName => {
	if (db[modelName].associate) {
		db[modelName].associate(db);
	}
});

await sequelize.sync();

db.sequelize = sequelize;
db.Sequelize = Sequelize;

module.exports = db;
{'fraction_non_alphanumeric': 0.19403453689167974, 'fraction_numerical': 0.002511773940345369, 'mean_word_length': 4.130434782608695, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3473828', 'n_tokens_mistral': 1180, 'n_tokens_neox': 1115, 'n_words': 187}