From f370a2fe684e4cfc9db5b96b1355d1c129cb261b Mon Sep 17 00:00:00 2001 From: "HRG @ SCExC" Date: Sun, 4 Feb 2024 10:11:47 -0500 Subject: [PATCH] nice --- index.js | 3 +++ migrations/000_bootstrap_db.sql | 8 -------- 2 files changed, 3 insertions(+), 8 deletions(-) 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