diff --git a/index.js b/index.js index 28b82e7..85af9a5 100644 --- a/index.js +++ b/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); diff --git a/migrations/000_bootstrap_db.sql b/migrations/000_bootstrap_db.sql index 7a8d75c..ab60fe2 100644 --- a/migrations/000_bootstrap_db.sql +++ b/migrations/000_bootstrap_db.sql @@ -35,13 +35,6 @@ CREATE TABLE routes ( FOREIGN KEY(structure_id) REFERENCES structures(structure_id), FOREIGN KEY(user_id) REFERENCES users(user_id) ); -CREATE TABLE migrations ( - migration_id INTEGER PRIMARY KEY AUTOINCREMENT, - db_id INTEGER, - sql_content TEXT NOT NULL, - name TEXT NOT NULL, - FOREIGN KEY(db_id) REFERENCES dbs(db_id) -); CREATE TABLE structure_dbs ( db_id INTEGER, structure_id INTEGER, @@ -56,4 +49,3 @@ CREATE TABLE structure_templates ( FOREIGN KEY(template_id) REFERENCES templates(template_id), FOREIGN KEY(structure_id) REFERENCES structures(structure_id) ); -a