Skip to content

Instantly share code, notes, and snippets.

@hinrikus
Created May 14, 2025 21:17
Show Gist options
  • Select an option

  • Save hinrikus/918a1d3ccb8daa22f5c2fa4b0ee0048f to your computer and use it in GitHub Desktop.

Select an option

Save hinrikus/918a1d3ccb8daa22f5c2fa4b0ee0048f to your computer and use it in GitHub Desktop.
Downgrade gitea database (postgresql) from 1.23 to 1.22 revision 310 to 298 for possible migration to forgejo
-- make sure you have a backup
-- tested only with postgresql
alter table issue drop column time_estimate ; -- 311
alter table protected_branch drop column priority; -- 310
drop index "IDX_notification_commit_id", "IDX_notification_issue_id", "IDX_notification_repo_id" , "IDX_notification_source", "IDX_notification_status", "IDX_notification_u_s_uu" , "IDX_notification_updated_by", "IDX_notification_user_id"; -- 309
drop index "IDX_action_r_u_d", "IDX_action_au_r_c_u_d", "IDX_action_c_u", "IDX_action_c_u_d"; -- 308
-- 307 was only a data migration fix for dates after year 9999
alter table protected_branch drop column block_admin_merge_override; -- 306
drop table repo_license; -- 305
alter table release drop column sha1; -- 304
alter table comment drop column comment_meta_data; -- 303
alter table action_task drop column stopped, drop column log_expired; -- 302
alter table oauth2_application drop column skip_secondary_authorization; -- 301
alter table protected_branch drop column can_force_push, drop column enable_force_push_allowlist,drop column force_push_allowlist_user_i_ds, drop column force_push_allowlist_team_i_ds, drop column force_push_allowlist_deploy_keys; -- 300
alter table issue drop column content_version; alter table comment drop column content_version; -- 299
update version set version=298;
@eta-orionis
Copy link

Did this work correctly? Asking because, according to [1] and [2], the database row value is "last migration number + 1". So if 298 is the last migration applied from v1.22, the version in line 22 above needs to be set to 299...

[1] https://github.com/go-gitea/gitea/blob/12a81d38c1d2d0dc3bba3dc6b01d474000864d7d/models/migrations/migrations.go#L69
[2] https://github.com/go-gitea/gitea/blob/12a81d38c1d2d0dc3bba3dc6b01d474000864d7d/models/migrations/migrations.go#L368

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment