When the database schema is modified, a migration script must be written into a vXXX.go
file in the migrations directory of the models
package. When the corresponding pull request requires discussions that last during weeks (which is likely because the database modifications are carefully reviewed), the odds that another pull request is merged and conflicts is high. The vXXX.go
file has to be renamed which painful. To avoid this, it is possible to do the following.
- Add the call to the migration function before the
migrations
variable instead of after, like so:
var migrations = append(gitea_migrations, []Migration{
NewMigration("Add Index field to comments", addCommentIndex),
}...)
var gitea_migrations = []Migration{
// Gitea 1.5.0 ends at v69
- Name the file
v1000.go
or anything that is unlikely to be used any time soon