Migrating from PostgreSQL to MSSQL

I just migrated our Gitea install from a local PostgreSQL database to a MSSQL server managed by our IT department.

This is what I did:

  1. Stop Gitea
  2. Do a dump with the --database mssql argument
  3. Extract the .sql file from the zip
  4. To enable running it multiple times for testing, I inserted “drop tables” before the creation of the tables. Search for IF NOT EXISTS \(SELECT \[name\] FROM sys\.tables WHERE \[name\] = '\[(.+)\]' \) replace with DROP TABLE IF EXISTS [$1];
  5. Add “SET IDENTITY_INSERT [XXXX] OFF;” after every table that sets is to ON (I did this manually)
  6. Remove SET IDENTITY_INSERT [notification] ON; for any table that did not have an IDENTITY column.
  7. Run the script on the new MSSQL database.
  8. Change the gitea config file to use the MSSQL database instead of the old PostgreSQL
  9. Start Gitea again
  10. Login and test

This worked for me, YMMV.