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

🔨 Ensures all active users have at least a product's group (🗃️) #5222

Merged

Conversation

pcrespov
Copy link
Member

@pcrespov pcrespov commented Jan 9, 2024

What do these changes do?

This PR adds a migration script that will assign the default product on all ACTIVE users that have no product associated. This will guarantee that all ACTIVE users have at least an associated product

  • This is a pre-condition for the product-based login Login bound to product #5117
  • This scenario is encountered on users created before the product feature was created. Currently all new users are automatically added to a product (see invitation workflow)

Related issue/s

How to test

Before the migration some active users might not have at least a product group. After the migration all users should have a product group.

To see the default product run ... and check the first

SELECT p.group_id, p.name
FROM products p
WHERE p.group_id IS NOT NULL
ORDER BY p.priority ASC

Run this query before (should list users to update) and after migration (should have none)

SELECT u.id, u.email
FROM users u
WHERE u.id NOT IN (
	SELECT utg.uid
	FROM user_to_groups utg
	WHERE utg.gid IN (
		SELECT p.group_id
		FROM products p
	)
)
AND u.status = 'ACTIVE';
  • tested against postgres data in master deploy

Dev Checklist

DevOps

  • 🗃️ users table is affected

Copy link

codecov bot commented Jan 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f533257) 87.3% compared to head (22f17d9) 87.8%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #5222     +/-   ##
========================================
+ Coverage    87.3%   87.8%   +0.4%     
========================================
  Files        1204    1093    -111     
  Lines       50725   46684   -4041     
  Branches     1149     577    -572     
========================================
- Hits        44326   41026   -3300     
+ Misses       6149    5529    -620     
+ Partials      250     129    -121     
Flag Coverage Δ
integrationtests 64.9% <ø> (ø)
unittests 85.4% <ø> (+0.2%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 195 files with indirect coverage changes

@pcrespov pcrespov self-assigned this Jan 9, 2024
@pcrespov pcrespov added the a:database associated to postgres service and postgres-database package label Jan 9, 2024
@pcrespov pcrespov added this to the This is Sparta! milestone Jan 9, 2024
@pcrespov pcrespov marked this pull request as ready for review January 9, 2024 16:29
@pcrespov pcrespov changed the title WIP: 🔨 Ensures all active users have at least a product's group 🔨 Ensures all active users have at least a product's group Jan 9, 2024
@pcrespov pcrespov changed the title 🔨 Ensures all active users have at least a product's group 🔨 Ensures all active users have at least a product's group (🗃️) Jan 9, 2024
Copy link

sonarqubecloud bot commented Jan 9, 2024

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@pcrespov pcrespov requested review from GitHK and YuryHrytsuk January 9, 2024 16:42
@pcrespov pcrespov enabled auto-merge (squash) January 9, 2024 17:46
@pcrespov pcrespov merged commit 6a43d20 into ITISFoundation:master Jan 10, 2024
55 checks passed
@pcrespov pcrespov deleted the is5117/migrate-users-wo-groups branch January 10, 2024 12:50
@matusdrobuliak66 matusdrobuliak66 mentioned this pull request Feb 14, 2024
39 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:database associated to postgres service and postgres-database package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants