Change ownership of issues/comments/PR from Github user to Gitea user after migration #3561

Closed
opened 2025-11-02 05:17:22 -06:00 by GiteaMirror · 10 comments
Owner

Originally created by @mrsdizzie on GitHub (Jul 10, 2019).

Now that #7293 has happened, I think we have a good path to give ownership of migrated issues/comments/PRs to local Gitea users after a repo is migrated from Github.

When migrating, we store the Github user ID in the issues and comments table as original_author_id which means that we can match them if admin sets up Github as Authentication Source and a local user links their Github account.

For changing ownership we should create a task that compares external_login_id from external_users_table with original_author_id in issues/comments. Then change the poster_id of the issue/comment from the user who ran the migration to the local Gitea user who has a matching Github ID (external_login_user.user_id).

At this time we should also NULL the original_author string so the templates show the new Gitea user information and behave as normal.

I think we should offer this in 3 areas:

  • After the migration is run we should see if any of the items migrated match an already authenticated user and change the ownership then.

  • When somebody uses Github to authenticate we should see if their Github user ID is present in any migrated comments that still have original_author string and change ownership then

  • There should also be a simple interface in the admin area to manually input a original_author_id and choose an existing local user to assign the issues/comments too. This would give admin full control over what accounts are linked to what issues/comments and let them also revert any previous ownership change/run the task again if an error occurs.

Originally created by @mrsdizzie on GitHub (Jul 10, 2019). Now that #7293 has happened, I think we have a good path to give ownership of migrated issues/comments/PRs to local Gitea users after a repo is migrated from Github. When migrating, we store the Github user ID in the ```issues``` and ```comments``` table as ```original_author_id``` which means that we can match them if admin sets up Github as Authentication Source and a local user links their Github account. For changing ownership we should create a task that compares ```external_login_id``` from ```external_users_table``` with ```original_author_id``` in issues/comments. Then change the ```poster_id``` of the issue/comment from the user who ran the migration to the local Gitea user who has a matching Github ID (```external_login_user.user_id```). At this time we should also NULL the ```original_author``` string so the templates show the new Gitea user information and behave as normal. I think we should offer this in 3 areas: - After the migration is run we should see if any of the items migrated match an already authenticated user and change the ownership then. - When somebody uses Github to authenticate we should see if their Github user ID is present in any migrated comments that still have ```original_author``` string and change ownership then - There should also be a simple interface in the admin area to manually input a ```original_author_id``` and choose an existing local user to assign the issues/comments too. This would give admin full control over what accounts are linked to what issues/comments and let them also revert any previous ownership change/run the task again if an error occurs.
GiteaMirror added the issue/confirmedtype/enhancement labels 2025-11-02 05:17:22 -06:00
Author
Owner

@lunny commented on GitHub (Jul 11, 2019):

@mrsdizzie Do you have any plan to work on this?

@lunny commented on GitHub (Jul 11, 2019): @mrsdizzie Do you have any plan to work on this?
Author
Owner

@mrsdizzie commented on GitHub (Jul 11, 2019):

@mrsdizzie Do you have any plan to work on this?

I could try if what I said sounds good to you

@mrsdizzie commented on GitHub (Jul 11, 2019): > @mrsdizzie Do you have any plan to work on this? I could try if what I said sounds good to you
Author
Owner

@lunny commented on GitHub (Jul 12, 2019):

@mrsdizzie That's good to me.

@lunny commented on GitHub (Jul 12, 2019): @mrsdizzie That's good to me.
Author
Owner

@stale[bot] commented on GitHub (Sep 10, 2019):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale[bot] commented on GitHub (Sep 10, 2019): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
Author
Owner

@programmerjake commented on GitHub (Oct 14, 2019):

so, was this the last step before gitea can be migrated from github to gitea?

@programmerjake commented on GitHub (Oct 14, 2019): so, was this the last step before gitea can be migrated from github to gitea?
Author
Owner

@lunny commented on GitHub (Oct 14, 2019):

@programmerjake I think yes. But there is a bug need to be fixed. #8504 . After that, we will begin to migrate to gitea.com.

@lunny commented on GitHub (Oct 14, 2019): @programmerjake I think yes. But there is a bug need to be fixed. #8504 . After that, we will begin to migrate to gitea.com.
Author
Owner

@guillep2k commented on GitHub (Oct 14, 2019):

Will we do a test run were we can check things and all after migration for a few days (e.g. testmigration.gitea.com)?

@guillep2k commented on GitHub (Oct 14, 2019): Will we do a test run were we can check things and all after migration for a few days (e.g. testmigration.gitea.com)?
Author
Owner

@lunny commented on GitHub (Oct 15, 2019):

@guillep2k We can migrate gitea to a private repository to test if it works. A subdomain is unnecessary. And if there is no any problem. Then we can archive the old repository on github and then migrate formally.

@lunny commented on GitHub (Oct 15, 2019): @guillep2k We can migrate gitea to a private repository to test if it works. A subdomain is unnecessary. And if there is no any problem. Then we can archive the old repository on github and then migrate formally.
Author
Owner

@6543 commented on GitHub (Nov 7, 2019):

@lunny can you crosline this pr in #1029?

@6543 commented on GitHub (Nov 7, 2019): @lunny can you crosline this pr in #1029?
Author
Owner

@lunny commented on GitHub (Nov 7, 2019):

@6543 Done. Thanks!

@lunny commented on GitHub (Nov 7, 2019): @6543 Done. Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#3561