nice
This commit is contained in:
parent
80c6db1abd
commit
f370a2fe68
2 changed files with 3 additions and 8 deletions
3
index.js
3
index.js
|
|
@ -27,11 +27,14 @@ function applyMigrations() {
|
|||
);
|
||||
`);
|
||||
|
||||
|
||||
const migrationsDir = path.join(__dirname, '/migrations');
|
||||
const migrationFiles = fs.readdirSync(migrationsDir).filter(file => file.endsWith('.sql'));
|
||||
|
||||
migrationFiles.forEach(file => {
|
||||
const isApplied = db.prepare('SELECT filename FROM migrations WHERE filename = ?').get(file);
|
||||
|
||||
console.log(!isApplied, file)
|
||||
if (!isApplied) {
|
||||
const sql = fs.readFileSync(path.join(migrationsDir, file), 'utf-8');
|
||||
db.exec(sql);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue