diff --git a/config/migrations/005_drop_unused_columns.sql b/config/migrations/005_drop_unused_columns.sql new file mode 100644 index 0000000..619e550 --- /dev/null +++ b/config/migrations/005_drop_unused_columns.sql @@ -0,0 +1,5 @@ +ALTER TABLE settings +DROP COLUMN show_tick_mood; + +ALTER TABLE user +DROP COLUMN about; \ No newline at end of file diff --git a/src/Framework/Database/Database.php b/src/Framework/Database/Database.php index a8dc342..6d959aa 100644 --- a/src/Framework/Database/Database.php +++ b/src/Framework/Database/Database.php @@ -92,8 +92,16 @@ class Database{ throw new Exception("Could not read migration file: $file"); } - // Execute the migration SQL - $db->exec($sql); + // Remove comments and split by semicolon + $sql = preg_replace('/--.*$/m', '', $sql); + $statements = preg_split('/;\s*$/m', $sql, -1, PREG_SPLIT_NO_EMPTY); + + // Execute each statement + foreach ($statements as $statement){ + if (!empty($statement)){ + $db->exec($statement); + } + } } // Update db version