mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-24 02:59:59 +00:00
Seeding needs something to look for before it inserts, or a retry writes a second copy of everything it already wrote. sys_api already had one in (app_code, path, action). sys_menu had nothing usable: menu_name is pascalCase(appCode) + pascalCase(code), which is not injective - "list-all", "listAll" and "list_all" all become "ListAll" - so the original code cannot be recovered from it. Hence a new column. seed_code is nullable, against this repository's habit of NOT NULL DEFAULT '' for a new column, and deliberately. Every row that predates it has no meaningful value, and under a unique index an empty string collides with every other empty string while NULL collides with nothing. The convention exists because deleted_at's nullability broke a unique index; here nullability is what makes one possible. The unique index on sys_api cannot simply be created: a live database is known to hold historical duplicates - the demo site had eighteen. The migration looks first and refuses while naming the offending rows, rather than letting CREATE UNIQUE INDEX fail with a constraint error that names none. Same shape as 1786700003000's refuseOnDuplicates. Run against SQLite, MySQL 8.0 and PostgreSQL 15, including the CONCAT duplicate check, which had only ever been executed by SQLite's driver.