fix: resolve password migration crash and schema constraints

- Login bcrypt migration: write password_salt = '' instead of NULL,
  which violated the NOT NULL constraint and caused 500 errors
- Schema: widen password_hash from CHAR(64) to VARCHAR(100) for bcrypt
  compatibility, add DEFAULT '' to password_salt
- init-db: add ALTER TABLE migrations for existing databases
- app.js: enrich error logging with method, path, SQL error details
这个提交包含在:
Guoguo
2026-04-28 19:14:13 -07:00
父节点 4b6e577dfb
当前提交 4ec42e7816
修改 4 个文件,包含 7 行新增5 行删除
+2 -2
查看文件
@@ -128,8 +128,8 @@ CREATE TABLE IF NOT EXISTS operation_logs (
CREATE TABLE IF NOT EXISTS admin_accounts (
admin_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
username VARCHAR(64) NOT NULL,
password_hash CHAR(64) NOT NULL,
password_salt CHAR(32) NOT NULL,
password_hash VARCHAR(100) NOT NULL,
password_salt VARCHAR(32) NOT NULL DEFAULT '',
real_name VARCHAR(100) NOT NULL DEFAULT '',
role VARCHAR(32) NOT NULL DEFAULT 'admin',
status TINYINT NOT NULL DEFAULT 1,