mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-24 02:59:59 +00:00
uk_sys_menu_app_seed_code_del covers (app_code, seed_code, deleted_at) and is created by 1786700008000 with explicit SQL. The struct tag named the same index on SeedCode alone, and a named uniqueIndex tag collects only the fields carrying that name - so AutoMigrate on this model would build a unique index on seed_code by itself: stricter than the real one, and forbidding two applications from both having a "dir" node, which the composite key exists to allow. Worse than being stricter, it would win. The migration only creates its index when HasIndex says the name is free, so a schema built by AutoMigrate first keeps the wrong index and the migration steps over it without a word. The tag cannot express the real index: deleted_at comes from the ModelTime embed shared by every table, which no single model can add a tag to. So the tag goes and the migration is the only thing that creates it. No database is affected. The initial table migration AutoMigrates a frozen snapshot of this model that has neither app_code nor seed_code, and nothing else in the repository AutoMigrates the live one - which is why this stayed invisible until a test built the schema from the live model and seeded two applications, and got a unique-constraint failure on a seed code they are supposed to be able to share.