Migrations bug #911

Closed
opened 2025-11-02 03:41:11 -06:00 by GiteaMirror · 12 comments
Owner

Originally created by @Bwko on GitHub (Jul 23, 2017).

When migrating from gogs db version 16 the following happens:

Migrate v37.go uses the latest models.User. Some of the models.User columns do not exists, like keep_email_private. Resulting in the following error: ERROR: column "keep_email_private" does not exist.

After all migrations are done xorm "magically" creates the missing columns.

Solutions:

  1. Let xorm create all of the missing columns before the migrations.
  2. Only select the columns you need, in this case id & full_name
  3. Always add migrations for new columns
Originally created by @Bwko on GitHub (Jul 23, 2017). When migrating from gogs db version 16 the following happens: Migrate [v37.go](https://github.com/go-gitea/gitea/blob/master/models/migrations/v37.go#L19) uses the latest `models.User`. Some of the `models.User` columns do not exists, like `keep_email_private`. Resulting in the following error: `ERROR: column "keep_email_private" does not exist`. After all migrations are done xorm "magically" creates the missing columns. **Solutions:** 1. Let xorm create all of the missing columns before the migrations. 2. Only select the columns you need, in this case `id & full_name` 3. Always add migrations for new columns
GiteaMirror added the type/bug label 2025-11-02 03:41:11 -06:00
Author
Owner

@lafriks commented on GitHub (Jul 23, 2017):

I think 3 is must and if does not have migration, this should be fixed

@lafriks commented on GitHub (Jul 23, 2017): I think 3 is must and if does not have migration, this should be fixed
Author
Owner

@lunny commented on GitHub (Jul 24, 2017):

@andreynering has contributed https://github.com/go-xorm/xorm/tree/master/migrate. Maybe we can change the migrations method to that?

@lunny commented on GitHub (Jul 24, 2017): @andreynering has contributed `https://github.com/go-xorm/xorm/tree/master/migrate`. Maybe we can change the migrations method to that?
Author
Owner

@Bwko commented on GitHub (Jul 25, 2017):

I'd like option 1.
Xorm automatically creates all the columns and I don't see any reason why xorm can't create the columns before migrating.

@Bwko commented on GitHub (Jul 25, 2017): I'd like option 1. Xorm automatically creates all the columns and I don't see any reason why xorm can't create the columns before migrating.
Author
Owner

@bkcsoft commented on GitHub (Jul 26, 2017):

@lunny If we switch to that we'll loose all hopes of migrating from Gogs to Gitea in the future

@bkcsoft commented on GitHub (Jul 26, 2017): @lunny If we switch to that we'll loose all hopes of migrating from Gogs to Gitea in the future
Author
Owner

@lafriks commented on GitHub (Jul 26, 2017):

@Bwko that can make problems if you are upgrading from version where later column has been added to structure and in later removed and there is migration that converts it data to either other column or table for example

@lafriks commented on GitHub (Jul 26, 2017): @Bwko that can make problems if you are upgrading from version where later column has been added to structure and in later removed and there is migration that converts it data to either other column or table for example
Author
Owner

@lunny commented on GitHub (Jul 26, 2017):

@lafriks yes, but that's a bug.

@lunny commented on GitHub (Jul 26, 2017): @lafriks yes, but that's a bug.
Author
Owner

@andreynering commented on GitHub (Jul 26, 2017):

If we use the Xorm migrate package, even them we would have to keep existing migrations for a while. Also, this don't solve the migration from Gogs problem.

Also keep in mind it is not as stable as the Gorm version since it don't have recent fixes, etc.

There's no easy solution for this.

@andreynering commented on GitHub (Jul 26, 2017): If we use the Xorm migrate package, even them we would have to keep existing migrations for a while. Also, this don't solve the migration from Gogs problem. Also keep in mind it is not as stable as [the Gorm version](https://github.com/go-gormigrate/gormigrate) since it don't have recent fixes, etc. There's no easy solution for this.
Author
Owner

@Bwko commented on GitHub (Jul 28, 2017):

@lafriks You're right, then we need to go for solution 3

@Bwko commented on GitHub (Jul 28, 2017): @lafriks You're right, then we need to go for solution 3
Author
Owner

@sondr3 commented on GitHub (Aug 25, 2017):

I was just bit by this issue, and can't upgrade one of my older Gogs instances to the new Gitea 1.2-rc1.

@sondr3 commented on GitHub (Aug 25, 2017): I was just bit by this issue, and can't upgrade one of my older Gogs instances to the new Gitea 1.2-rc1.
Author
Owner

@strk commented on GitHub (Aug 25, 2017):

@lunny if this bug prevents upgrading from Gogs it should be considered of upmost importance, why postponing fix to 1.3.0 ? Maybe I misunderstood the severity and db 16 is not a supported Gogs version ?

@strk commented on GitHub (Aug 25, 2017): @lunny if this bug prevents upgrading from Gogs it should be considered of upmost importance, why postponing fix to 1.3.0 ? Maybe I misunderstood the severity and db 16 is not a supported Gogs version ?
Author
Owner

@sondr3 commented on GitHub (Aug 25, 2017):

I was upgrading from Gogs version 0.9.48.0722, but I can't tell from the Upgrading from Gogs info on the docs whether it's supported or not. It's not a major hassle for me, it was literally hosting a single repo but wanted to let you know.

@sondr3 commented on GitHub (Aug 25, 2017): I was upgrading from `Gogs version 0.9.48.0722`, but I can't tell from the Upgrading from Gogs info on the docs whether it's supported or not. It's not a major hassle for me, it was literally hosting a single repo but wanted to let you know.
Author
Owner

@strk commented on GitHub (Aug 27, 2017):

From docs:

Gogs versions up to 0.9.146 (db schema version 15) can be smoothly upgraded to Gitea.

So yes, it should be supported

@strk commented on GitHub (Aug 27, 2017): From docs: > Gogs versions up to 0.9.146 (db schema version 15) can be smoothly upgraded to Gitea. So yes, it should be supported
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#911