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

chore:system user and events created by userid migrations #5612

Merged
merged 12 commits into from
Dec 22, 2023

Conversation

daveleek
Copy link
Contributor

@daveleek daveleek commented Dec 12, 2023

About the changes

Migrations for:

  • Adds column created_by_user_id to events
  • Adds column is_system to users
  • Inserts unleash_system_user id -1337 to users

includes is_system: false in the activeUsers where filter

Tested by running:
select * into users_pre_check from users where id > -1; delete from users where id > -1;
before starting unleash, then inspecting users table after unleash has started and verifying that an 'admin' user has been created.

@daveleek daveleek requested a review from chriswk December 12, 2023 10:21
Copy link

vercel bot commented Dec 12, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Dec 22, 2023 8:58am
unleash-monorepo-frontend ⬜️ Ignored (Inspect) Visit Preview Dec 22, 2023 8:58am

Copy link
Member

@chriswk chriswk left a comment

Choose a reason for hiding this comment

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

Nice. :)

Copy link
Member

@chriswk chriswk left a comment

Choose a reason for hiding this comment

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

Once you've confirmed that this doesn't break creation of initial admin user I'm all for this.

Copy link
Member

@chriswk chriswk left a comment

Choose a reason for hiding this comment

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

Nice. I assume the where(is_system: false) will solve the creating admin user.

Copy link
Member

@nunogois nunogois left a comment

Choose a reason for hiding this comment

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

Adding a test like:

  • favor-permission-name-over-id.e2e.test.ts
  • dedupe-permissions.e2e.test.ts

Could potentially be useful just to validate the migration behavior.

@daveleek
Copy link
Contributor Author

Test added, I've updated the username of the system user @nunogois

INSERT INTO users
(id, name, username, email, created_by_user_id, is_system)
VALUES
(-1337, 'Unleash System', 'unleash_system_user', '[email protected]', -1337, true);
Copy link
Member

Choose a reason for hiding this comment

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

Even though I like -1337, I'm wondering if we should just use -1 instead.

expect(userResults[1].is_system).toEqual(false);
expect(userResults[1].id).toEqual(1);
expect(userResults[1].username).toEqual('testperson');
});
Copy link
Member

Choose a reason for hiding this comment

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

Nice 🏅

Copy link
Member

@nunogois nunogois left a comment

Choose a reason for hiding this comment

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

LGTM!

@daveleek daveleek merged commit 1dadd23 into main Dec 22, 2023
7 checks passed
@daveleek daveleek deleted the chore/system-user-events-created-by-userid-migrations branch December 22, 2023 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants