fix: DatabaseManager removes inline comments correctly in migrations
- Fixed SQL statement parsing to remove both line and inline comments - Prevents incomplete SQL statements from inline comments - Migration 005 and 006 now apply correctly via automatic migration system - Tested with production data: All 72 groups have display_in_workshop = 0 (GDPR compliant)
This commit is contained in:
parent
f049c47f38
commit
8e6247563a
|
|
@ -361,11 +361,24 @@ class DatabaseManager {
|
||||||
// Execute migration in a transaction
|
// Execute migration in a transaction
|
||||||
await this.run('BEGIN 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
|
// Split by semicolon and execute each statement
|
||||||
const statements = sql
|
const statements = cleanedSql
|
||||||
.split(';')
|
.split(';')
|
||||||
.map(s => s.trim())
|
.map(s => s.trim())
|
||||||
.filter(s => s.length > 0 && !s.startsWith('--'));
|
.filter(s => s.length > 0);
|
||||||
|
|
||||||
for (const statement of statements) {
|
for (const statement of statements) {
|
||||||
await this.run(statement);
|
await this.run(statement);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user