Home

How to "upgrade" from Gitea to Forgejo (not for the faint of heart!)

$$13085
https://lemmy.world/u/witten posted on Mar 16, 2026 18:06

Here’s the background: I’d been using Gitea for open source project hosting for a quite a while. So when the Forgejo fork started up, I thought to myself: Eh, I’ll see how that all unfolds and maybe look into it at some point. After all, Forgejo is a soft fork, so I can just switch over whenever.

But then Forgejo became a hard fork while I was busy with other stuff, and before I knew it, It seemed too late to switch unless I wanted to lose all my tickets and stuff.

Then I saw this post and read this background and decided it was time for me to switch to Forgejo, hard fork be damned.

But I’m very stubborn, and I still wanted to keep all of my Gitea data intact. So here’s what I did, and what you could do too:

Step one: Create a SQL “migration” that downgrades the Gitea database from the modern version you’re using to the last version that Forgejo supports upgrading, Gitea 1.22.6, from back when Forgejo was still a soft-ish fork. That means you’re effectively rolling back each migration from Gitea 1.25 all the way through 1.24 and 1.23.

When I did this, I used an LLM (specifically MiniMax with OpenCode) to generate the reverse mega-migration, feeding it this very outdated starting point as inspiration. But I totally understand if not everyone is comfortable with using AI. In fact, I really wasn’t either, but I figured this is a mostly mechanical one-off. If you don’t want to use AI, you can generate the reverse migration manually by combing through the migrations linked above.

I did find three mistakes the LLM made: 1. An off-by-one error in UPDATE version ... because the value should be the last migration number (298 in this case) plus one, 2. Some of the steps it generated to back out an individual migration were out of order, e.g. dropping the issue_pin table before copying data out of it, and 3. It apparently missed making one particular column (type in the review table) into an int instead of a varchar.

Once I fixed these issues (well, the ones I found ahead of time instead of after the fact), the mega-migration was ready to go.

(I’m not including the mega-migration here, because even if it worked for me, I don’t want to be responsible for people fucking up their systems if it doesn’t work for them. I’d much rather people be responsible for fucking up their own systems.)

Step two: Backup your Gitea database and files!!!

Step three: Stop Gitea and run the mega-rollback-migration against your Gitea database. This effectively downgrades the database to Gitea 1.22.6. You can optionally then deploy the Gitea 1.22.6 binary or container and start it up to poke around the Gitea web UI and verify that the downgrade worked. Then stop Gitea again.

Step four: Replace the Gitea binary or container with the last release of Forgejo to support upgrades from Gitea, Forgejo 10.0.3. Start Forgejo and try out the web UI to make sure it’s working.

Step five: Upgrade your Forgejo binary or container to the latest release of Forgejo, 14.0.3 at the time of this writing. Restart Forgejo and hopefully enjoy your newly “upgraded” instance, complete with all of your repos and ticket history!

https://lemmy.world/post/44345452
Reply
$$13106
https://lemmy.today/u/LodeMike posted on Mar 16, 2026 18:51
In reply to: https://lemmy.world/post/44345452

Literally

  1. Back up instance config and data
  2. Swap out ELF for same or newer Forgejo version.
https://lemmy.today/comment/22926453
Reply
$$13114
https://lemmy.world/u/witten posted on Mar 16, 2026 19:05
In reply to: https://lemmy.today/comment/22926453

Forgejo past 10.0.x is not compatible with Gitea’s database schema. Have you tried it?

https://lemmy.world/comment/22697798
Reply
$$13115
https://lemmy.today/u/LodeMike posted on Mar 16, 2026 19:06
In reply to: https://lemmy.world/comment/22697798

No

https://lemmy.today/comment/22926771
Reply
$$13122
https://lemmy.world/u/witten posted on Mar 16, 2026 19:12
In reply to: https://lemmy.today/comment/22926771

I haven’t either. 😄 But I’m just taking Forgejo’s docs on this at their word.

https://lemmy.world/comment/22697900
Reply
$$13140
https://discuss.tchncs.de/u/devtoolkit_api posted on Mar 16, 2026 19:39
In reply to: https://lemmy.world/post/44345452

Thanks for writing this up. I went through the same migration last year and can confirm — it is not as smooth as “just swap the binary” anymore since the hard fork.

A few extra tips that saved me headaches:

  • Backup everything first — obvious but worth emphasizing. Dump the database AND copy the entire data directory. pg_dump if you are on Postgres, or just copy the SQLite file.
  • Check your Gitea version first — Forgejo migration paths assume specific Gitea versions. If you are on an old Gitea, you might need to step through intermediate Gitea versions before jumping to Forgejo.
  • Webhooks and integrations — These survived the migration for me, but the API tokens did not. Had to regenerate them all.
  • Runner compatibility — If you use Gitea Actions/runners, make sure to switch to Forgejo’s runner binary too. They have diverged enough that mixing them causes subtle issues.

Overall though, Forgejo has been great post-migration. More responsive to community issues and the federation work they are doing is exciting.

https://discuss.tchncs.de/comment/24570609
Reply
$$13147
https://piefed.social/u/eleijeep posted on Mar 16, 2026 19:50
In reply to: https://lemmy.world/post/44345452

Using an LLM to do a database migration is like asking your neighbour’s kid to file your taxes.

https://piefed.social/comment/10558926
Reply
$$13157
https://programming.dev/u/moonpiedumplings posted on Mar 16, 2026 20:01
In reply to: https://lemmy.world/post/44345452

Yes. But this is a lot. It may be easier to use Forgejo’s built in migration tools, to copy over repositories along with their issues and other info. You would have to rebuild the admin parts of the site, like “organizations” and user privileges. (Well if you are using oauth and mapping users from oautb groups then you don’t…). And I don’t know if it’s automated for a many, many repos. But it’s just a click click click in the gui.

I remember there was a tool, I think it was related to forgefed, that could do batch repo migrations via the cli. I can’t find it anymore though.

https://programming.dev/comment/22757782
Reply
$$13193
https://lemmy.world/u/witten posted on Mar 16, 2026 21:00
In reply to: https://piefed.social/comment/10558926

Lol that’s a good idea… I hate doing taxes!

https://lemmy.world/comment/22699759
Reply
$$13197
https://lemmy.world/u/witten posted on Mar 16, 2026 21:02
In reply to: https://programming.dev/comment/22757782

That would be ideal if it worked, yeah. But personally I wouldn’t want to manually recreate the bits that it didn’t support migrating. I realize everyone’s instance and situation is different.

https://lemmy.world/comment/22699793
Reply
$$13203
https://lemmy.ml/u/mbirth posted on Mar 16, 2026 21:09
In reply to: https://lemmy.world/post/44345452

I’m staying with Gitea. They’ve created the Ltd. so they can sell professional support as most businesses will want a proper invoice. I don’t see anything wrong with that. Also, ForgeJo was promising federation which is still a WIP several years later. And, the one time I’ve tried ForgeJo it shit itself when I’ve added an emoji to my username. For some reason Gitea didn’t have any problem with that.

https://lemmy.ml/comment/24578868
Reply
$$13206
https://lemmy.world/u/witten posted on Mar 16, 2026 21:13
In reply to: https://lemmy.ml/comment/24578868

Personally, I think it’s great to have multiple options in this space. I think we can all agree that self-hosting (or using Forgejo/Gitea on a smaller platform, e.g. Codeberg) is preferable to centralizing absolutely everything on Microsoft GitHub.

https://lemmy.world/comment/22700009
Reply
$$13329
https://feddit.org/u/30p87 posted on Mar 17, 2026 00:14
In reply to: https://lemmy.world/comment/22699759

And you love going to jail for gross tax fraud?

https://feddit.org/comment/12057098
Reply
$$13337
https://lemmy.world/u/witten posted on Mar 17, 2026 00:41
In reply to: https://feddit.org/comment/12057098

I think you underestimate how much of step up it would be for the neighbor’s kid to do my taxes.

https://lemmy.world/comment/22703078
Reply
$$13355
https://lemmy.world/u/ikidd posted on Mar 17, 2026 01:37
In reply to: https://lemmy.world/post/44345452

The time to do this was before the hard fork.

The easy way to do this is make your user(s) and use Forgejo’s migration functions. Why would you muddy this up like this? Just nuke and pave, it would take a tenth of the time and be a hell of a lot less chancy in their long term.

https://lemmy.world/comment/22703681
Reply
$$13362
https://lemmy.world/u/witten posted on Mar 17, 2026 02:00
In reply to: https://lemmy.world/comment/22703681

The best time to do was before the hard fork. The second best time was was, well, now. Also, I am the user(s) of this former Gitea instance, just in terms of who owns the repos on it. And like I said above, I didn’t want to lose all of the data that the built-in migration feature wouldn’t migrate.

https://lemmy.world/comment/22703950
Reply
$$13368
https://lemmy.zip/u/possiblylinux127 posted on Mar 17, 2026 02:30
In reply to: https://lemmy.world/post/44345452

There’s a better way

Start with the last Forgejo version to be compatible with with Gitea and then slowly upgrade Forgejo one version at a time. This should be trivial to do and can be scripted easily.

https://lemmy.zip/comment/25302261
Reply
$$13370
https://programming.dev/u/moonpiedumplings posted on Mar 17, 2026 02:35
In reply to: https://lemmy.ml/comment/24578868

If you are not a Gitea customer, you are not being informed of security updates in a timely manner:

Gitea repeatedly makes choices that leave Gitea admins exposed to known vulnerabilities during extended periods of time. For instance Gitea spent resources to undergo a SOC2 security audit for its SaaS offering while critical vulnerabilities demanded a new release. Advance notice of security releases is for customers only.

https://forgejo.org/compare-to-gitea/#security

Also, ForgeJo was promising federation which is still a WIP several years later.

Oh no, it doesn’t do the big feature™. I guess it’s unusable now.

I wish people would realize that software still works and is excellent even without the various flagship features. I use Kubernetes on a single node. I know there are people who use matrix without federation and e2ee because it’s actually a really good chat app, it just struggles with the performance demands of federation, and the e2ee ux isn’t quite there yet.

https://programming.dev/comment/22763461
Reply
$$13380
https://lemmy.world/u/witten posted on Mar 17, 2026 03:09
In reply to: https://lemmy.zip/comment/25302261

I don’t understand. How would that help switching from a Gitea 1.25.x instance?

https://lemmy.world/comment/22704639
Reply
$$13419
https://lemmy.zip/u/possiblylinux127 posted on Mar 17, 2026 05:36
In reply to: https://lemmy.world/comment/22704639

Shoot your right

Never mind I guess. You would need to downgrade which I don’t think is possible

https://lemmy.zip/comment/25304194
Reply
$$13520
https://pawb.social/u/savvywolf posted on Mar 17, 2026 11:52
In reply to: https://programming.dev/comment/22763461

Has Gitea even given any indication that they want to work on federation themselves?

https://pawb.social/comment/21197304
Reply
$$13559
https://lemmy.ml/u/mbirth posted on Mar 17, 2026 13:06
In reply to: https://programming.dev/comment/22763461

If you are not a Gitea customer, you are not being informed of security updates in a timely manner

I don’t need a notification of issues, I need a notification of when there’s a new version to roll out. And that can be solved by using things like WatchTower or setting up release notifications on GitHub.

And, of course, a comparison hosted on ForgeJo’s webpage will make it out that they’re “the better choice”.

Also, ForgeJo was promising federation which is still a WIP several years later.

Oh no, it doesn’t do the big feature™. I guess it’s unusable now.

Well, that was the one big distinguishing thing between the two, back when ForgeJo was the new kid on the block. ForgeJo wanted to make it a priority to implement federation.

And I never said it’s unusable - it’s just that I, personally, don’t see any reason to switch from Gitea to ForgeJo.

https://lemmy.ml/comment/24590726
Reply
$$13562
https://lemy.lol/u/melfie posted on Mar 17, 2026 13:08
In reply to: https://lemmy.world/post/44345452

I just spun up Forgejo and pushed up all my repos by hand because I’m lazy.

https://lemy.lol/comment/24802052
Reply
$$13601
https://lemmy.world/u/greenaar posted on Mar 17, 2026 14:06
In reply to: https://lemmy.world/post/44345452

I wrote a python handler to query the GItea api and either mirror from source repos that were a straight mirror, or full clone/standalone local repos. Also handled creating orgs (using the forgejo api), since I wasn’t going to do any of that by hand.

https://lemmy.world/comment/22711492
Reply
$$13645
https://lemmy.world/u/witten posted on Mar 17, 2026 15:18
In reply to: https://lemmy.world/comment/22711492

That sounds pretty nice. Did it also handle issues and comments and stuff?

https://lemmy.world/comment/22712738
Reply
$$13647
https://lemmy.world/u/witten posted on Mar 17, 2026 15:20
In reply to: https://lemy.lol/comment/24802052

Sounds like not lazy at all. If anything more work depending on the number of repos!

https://lemmy.world/comment/22712764
Reply
$$13648
https://lemmy.world/u/witten posted on Mar 17, 2026 15:22
In reply to: https://lemmy.zip/comment/25304194

Well, not officially supported anyway…

https://lemmy.world/comment/22712787
Reply
$$13650
https://lemy.lol/u/melfie posted on Mar 17, 2026 15:23
In reply to: https://lemmy.world/comment/22712764

I had like 10 repos and nothing of much value in the DB, so it was quick to create the repos and push them up.

https://lemy.lol/comment/24804515
Reply
$$16078
https://lemmy.world/u/greenaar posted on Mar 22, 2026 17:49
In reply to: https://lemmy.world/comment/22712738

I didn’t have any to move, so I didn’t allow for that. I’d assume not though.

https://lemmy.world/comment/22808600
Reply