-- eduSign 2026-07-02：管理員改用 Google 帳號白名單（比照 emms），淘汰本地帳密 t_admin
-- 舊表（username/password/permission）改名保留，新表只記 Google email @ 前段
-- 執行：mysql --default-character-set=utf8mb4 -u root -p < migrate_20260702_google_admin.sql
USE eduSign;

RENAME TABLE t_admin TO t_admin_bak_20260702;

CREATE TABLE IF NOT EXISTS t_admin (
  id INT NOT NULL AUTO_INCREMENT,
  account VARCHAR(50) NOT NULL COMMENT 'Google email @ 前段',
  name VARCHAR(50) NOT NULL DEFAULT '',
  active TINYINT(1) NOT NULL DEFAULT 1,
  PRIMARY KEY (id),
  UNIQUE KEY uk_account (account)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT IGNORE INTO t_admin (account, name, active) VALUES
  ('yangmc', '楊名傑', 1),
  ('it', '資訊組', 1);

-- 舊表內容（供對照）與新表現況
SELECT id, username, name, email, permission FROM t_admin_bak_20260702;
SELECT id, account, name, active FROM t_admin;
