-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v3: Create 'roles' view to back Role model, instead of dataset
We had a dataset representing the union of the 7 roles tables that was backing the Role Sequel model. This change adds a migration to create a view that represents the same union, and switches the model to be backed by the view instead. This solves a problem introduced as part of #164176828, where the PollableJob model was trying to run a query against a table called `roles` to check if a role existed. Since that table didn't exist, it was failing. Now, there is a view with that name, so those queries work. [Finishes #164176828] Authored-by: Reid Mitchell <[email protected]>
- Loading branch information
Showing
4 changed files
with
79 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
Sequel.migration do | ||
change do | ||
not_specified = -1 | ||
|
||
create_view :roles, | ||
self[:organizations_users].select( | ||
Sequel.as('organization_user', :type), | ||
Sequel.as(:role_guid, :guid), | ||
:user_id, | ||
:organization_id, | ||
Sequel.as(not_specified, :space_id), | ||
:created_at, | ||
:updated_at | ||
).union( | ||
self[:organizations_managers].select( | ||
Sequel.as('organization_manager', :type), | ||
Sequel.as(:role_guid, :guid), | ||
:user_id, | ||
:organization_id, | ||
Sequel.as(not_specified, :space_id), | ||
:created_at, | ||
:updated_at) | ||
).union( | ||
self[:organizations_billing_managers].select( | ||
Sequel.as('organization_billing_manager', :type), | ||
Sequel.as(:role_guid, :guid), | ||
:user_id, | ||
:organization_id, | ||
Sequel.as(not_specified, :space_id), | ||
:created_at, | ||
:updated_at) | ||
).union( | ||
self[:organizations_auditors].select( | ||
Sequel.as('organization_auditor', :type), | ||
Sequel.as(:role_guid, :guid), | ||
:user_id, | ||
:organization_id, | ||
Sequel.as(not_specified, :space_id), | ||
:created_at, | ||
:updated_at) | ||
).union( | ||
self[:spaces_developers].select( | ||
Sequel.as('space_developer', :type), | ||
Sequel.as(:role_guid, :guid), | ||
:user_id, | ||
Sequel.as(not_specified, :organization_id), | ||
:space_id, | ||
:created_at, | ||
:updated_at) | ||
).union( | ||
self[:spaces_auditors].select( | ||
Sequel.as('space_auditor', :type), | ||
Sequel.as(:role_guid, :guid), | ||
:user_id, | ||
Sequel.as(not_specified, :organization_id), | ||
:space_id, | ||
:created_at, | ||
:updated_at) | ||
).union( | ||
self[:spaces_managers].select( | ||
Sequel.as('space_manager', :type), | ||
Sequel.as(:role_guid, :guid), | ||
:user_id, | ||
Sequel.as(not_specified, :organization_id), | ||
:space_id, | ||
:created_at, | ||
:updated_at)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters