Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unique constraint for orgs #4923

Merged
merged 2 commits into from
Mar 3, 2025
Merged

Fix unique constraint for orgs #4923

merged 2 commits into from
Mar 3, 2025

Conversation

xoxys
Copy link
Member

@xoxys xoxys commented Mar 3, 2025

In #4817 we changed the org lookup from name="name" to name="name AND forge_id="forgeid" (https://github.com/woodpecker-ci/woodpecker/pull/4817/files#diff-eb104e63f04fbe20f88199ac5e15aa7164690f990773a43cedb458c083b16260R84) while the unique constraint was still "UQE_orgs_name" UNIQUE, btree (name).

With this change, the constraint was changes to "UQE_orgs_s" UNIQUE, btree (forge_id, name)

@xoxys xoxys requested a review from a team March 3, 2025 09:48
@xoxys xoxys added bug Something isn't working server labels Mar 3, 2025
@qwerty287
Copy link
Contributor

How can this fix the issue? Do we try to re-insert the org? There is no real multi-forge support yet where this could occur.

@xoxys
Copy link
Member Author

xoxys commented Mar 3, 2025

Fair. I checked my local test instance again. I had an entry in the orgs table with forge_id=0. Don't ask me how it gets there, but this has triggered the error message from the issue with v3.2 while it has not with v3.1.

woodpecker_server=# select * from orgs;
 id | forge_id |    name    | is_user | private 
----+----------+------------+---------+---------
  1 |        0 | woodpecker | t       | f
  2 |        1 | testorg    | f       | f
  3 |        1 | testorg2   | f       | f

I might got trapped by this weird state, however, the constraint should still be fixed and match the changed lookup.

Copy link

codecov bot commented Mar 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 26.25%. Comparing base (0ecd57d) to head (ca70160).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4923      +/-   ##
==========================================
+ Coverage   26.23%   26.25%   +0.01%     
==========================================
  Files         399      399              
  Lines       28397    28397              
==========================================
+ Hits         7451     7456       +5     
+ Misses      20273    20268       -5     
  Partials      673      673              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@qwerty287 qwerty287 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't fix the issue, see #4918 (comment) for the solution, but is good anyways.

@qwerty287 qwerty287 merged commit a3cc61b into main Mar 3, 2025
9 checks passed
@qwerty287 qwerty287 deleted the fix-org-constraint branch March 3, 2025 16:33
@woodpecker-bot woodpecker-bot mentioned this pull request Mar 3, 2025
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants