define repository name uniqueness per namespace

This commit is contained in:
Jabberwocky238
2026-07-30 01:32:31 -04:00
parent 8d99f3bc20
commit ec95339f13
-10
View File
@@ -111,15 +111,5 @@ func migrateLegacySQLite(engine *xorm.Engine) error {
return fmt.Errorf("migrate repo column repo_name to name: %w", err) return fmt.Errorf("migrate repo column repo_name to name: %w", err)
} }
} }
if len(columns) > 0 {
// Older schemas accidentally made namespace_id unique by itself, limiting
// a namespace to one repository. The model key is (namespace_id, name).
if _, err := engine.Exec("DROP INDEX IF EXISTS UQE_repo_cred"); err != nil {
return fmt.Errorf("drop legacy repo unique index: %w", err)
}
if _, err := engine.Exec("CREATE UNIQUE INDEX IF NOT EXISTS UQE_repo_cred ON repo (namespace_id, name)"); err != nil {
return fmt.Errorf("create repo unique index: %w", err)
}
}
return nil return nil
} }