mirror of
https://github.com/screentinker/screentinker.git
synced 2026-06-20 13:13:20 -06:00
fix(db): count only ADD COLUMN as new migrations in boot log (#37 follow-up)
The boot summary counted any non-throwing statement, so UPDATE/index migrations (which always succeed) made a healthy DB report 'applied N new column migration(s)' every boot. Count only a successful ALTER ... ADD COLUMN (genuinely new), so the line appears only when a column was actually added.
This commit is contained in:
parent
7ef3e2eb93
commit
bae70e9154
|
|
@ -185,9 +185,14 @@ const migrations = [
|
||||||
// a swallowed failure left users.must_change_password absent -> total auth lockout).
|
// a swallowed failure left users.must_change_password absent -> total auth lockout).
|
||||||
let _migApplied = 0;
|
let _migApplied = 0;
|
||||||
for (const sql of migrations) {
|
for (const sql of migrations) {
|
||||||
|
// Only a successful ADD COLUMN means a genuinely-new column (it would throw
|
||||||
|
// "duplicate column" if it already existed). UPDATE/index statements always
|
||||||
|
// succeed, so they must NOT count toward "new migrations applied" or the boot
|
||||||
|
// would falsely report work on every healthy start.
|
||||||
|
const isAddColumn = /alter\s+table\s+\S+\s+add\s+column/i.test(sql);
|
||||||
try {
|
try {
|
||||||
db.exec(sql);
|
db.exec(sql);
|
||||||
_migApplied++;
|
if (isAddColumn) _migApplied++;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!/duplicate column name|already exists/i.test(e.message)) {
|
if (!/duplicate column name|already exists/i.test(e.message)) {
|
||||||
console.error(`[migrate] FAILED: ${sql}\n -> ${e.message}`);
|
console.error(`[migrate] FAILED: ${sql}\n -> ${e.message}`);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue