diff --git a/backend/src/database/DatabaseManager.js b/backend/src/database/DatabaseManager.js index a77a260..f768ea1 100644 --- a/backend/src/database/DatabaseManager.js +++ b/backend/src/database/DatabaseManager.js @@ -361,11 +361,24 @@ class DatabaseManager { // Execute migration in a transaction await this.run('BEGIN TRANSACTION'); + // Remove comments (both line and inline) before splitting + const cleanedSql = sql + .split('\n') + .map(line => { + // Remove inline comments (everything after --) + const commentIndex = line.indexOf('--'); + if (commentIndex !== -1) { + return line.substring(0, commentIndex); + } + return line; + }) + .join('\n'); + // Split by semicolon and execute each statement - const statements = sql + const statements = cleanedSql .split(';') .map(s => s.trim()) - .filter(s => s.length > 0 && !s.startsWith('--')); + .filter(s => s.length > 0); for (const statement of statements) { await this.run(statement);