-
Notifications
You must be signed in to change notification settings - Fork 29
Add default Derivation Group associations for Plans at the Model level #1831
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
Open
pranav-super
wants to merge
3
commits into
develop
Choose a base branch
from
feature/model_derivation_group_associations_v2
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
53 changes: 53 additions & 0 deletions
53
deployment/hasura/metadata/databases/tables/merlin/model_derivation_group.yaml
This file contains hidden or 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,53 @@ | ||
| table: | ||
| name: model_derivation_group | ||
| schema: merlin | ||
| configuration: | ||
| custom_name: "model_derivation_group" | ||
| object_relationships: | ||
| - name: mission_model | ||
| using: | ||
| foreign_key_constraint_on: model_id | ||
| - name: derivation_group | ||
| using: | ||
| foreign_key_constraint_on: derivation_group_name | ||
| array_relationships: | ||
| - name: external_events | ||
| using: | ||
| manual_configuration: | ||
| remote_table: | ||
| name: external_event | ||
| schema: merlin | ||
| column_mapping: | ||
| derivation_group_name: derivation_group_name | ||
| select_permissions: | ||
| - role: aerie_admin | ||
| permission: | ||
| columns: '*' | ||
| filter: {} | ||
| allow_aggregations: true | ||
| - role: user | ||
| permission: | ||
| columns: '*' | ||
| filter: {} | ||
| allow_aggregations: true | ||
| - role: viewer | ||
| permission: | ||
| columns: '*' | ||
| filter: {} | ||
| allow_aggregations: true | ||
| insert_permissions: | ||
| - role: aerie_admin | ||
| permission: | ||
| columns: [model_id, derivation_group_name] | ||
| check: {} | ||
| - role: user | ||
| permission: | ||
| columns: [model_id, derivation_group_name] | ||
| check: {"mission_model": {"owner": {"_eq": "X-Hasura-User-Id"}}} | ||
| delete_permissions: | ||
| - role: aerie_admin | ||
| permission: | ||
| filter: {} | ||
| - role: user | ||
| permission: | ||
| filter: {"mission_model": {"owner": {"_eq": "X-Hasura-User-Id"}}} |
This file contains hidden or 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
5 changes: 5 additions & 0 deletions
5
deployment/hasura/migrations/Aerie/35_model_derivation_group/down.sql
This file contains hidden or 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,5 @@ | ||
| drop trigger populate_derivation_groups_new_plan_trigger on merlin.plan; | ||
| drop function merlin.populate_derivation_groups_new_plan cascade; | ||
| drop table merlin.model_derivation_group cascade; | ||
|
|
||
| call migrations.mark_migration_rolled_back('35'); |
47 changes: 47 additions & 0 deletions
47
deployment/hasura/migrations/Aerie/35_model_derivation_group/up.sql
|
Mythicaeda marked this conversation as resolved.
|
This file contains hidden or 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,47 @@ | ||
| create table merlin.model_derivation_group ( | ||
| model_id integer not null, | ||
| derivation_group_name text not null, | ||
|
|
||
| constraint model_derivation_group_pkey | ||
| primary key (model_id, derivation_group_name), | ||
| constraint mdg_model_exists | ||
| foreign key (model_id) | ||
| references merlin.mission_model(id) | ||
| on delete cascade, | ||
| constraint mdg_derivation_group_exists | ||
| foreign key (derivation_group_name) | ||
| references merlin.derivation_group(name) | ||
| on update cascade | ||
| on delete restrict | ||
| ); | ||
|
|
||
| comment on table merlin.model_derivation_group is e'' | ||
| 'The default set of derivation groups that any new plans created using this model would have linked to them.'; | ||
|
|
||
| comment on column merlin.model_derivation_group.model_id is e'' | ||
| 'The model with which the derivation group is associated.'; | ||
| comment on column merlin.model_derivation_group.derivation_group_name is e'' | ||
| 'The derivation group being associated with the model.'; | ||
|
|
||
|
|
||
| create function merlin.populate_derivation_groups_new_plan() | ||
| returns trigger | ||
| language plpgsql as $$ | ||
| begin | ||
| insert into merlin.plan_derivation_group (plan_id, derivation_group_name) | ||
| select new.id, mdg.derivation_group_name | ||
| from merlin.model_derivation_group mdg | ||
| where mdg.model_id = new.model_id; | ||
| return new; | ||
| end; | ||
| $$; | ||
|
|
||
| comment on function merlin.populate_derivation_groups_new_plan() is e'' | ||
| 'Populates the plan''s derivation group associations with the contents of its model''s derivation group associations.'; | ||
|
|
||
| create trigger populate_derivation_groups_new_plan_trigger | ||
| after insert on merlin.plan | ||
| for each row | ||
| execute function merlin.populate_derivation_groups_new_plan(); | ||
|
|
||
| call migrations.mark_migration_applied('35'); |
This file contains hidden or 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 hidden or 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
24 changes: 24 additions & 0 deletions
24
deployment/postgres-init-db/sql/tables/merlin/external_events/model_derivation_group.sql
This file contains hidden or 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,24 @@ | ||
| create table merlin.model_derivation_group ( | ||
| model_id integer not null, | ||
| derivation_group_name text not null, | ||
|
|
||
| constraint model_derivation_group_pkey | ||
| primary key (model_id, derivation_group_name), | ||
| constraint mdg_model_exists | ||
| foreign key (model_id) | ||
| references merlin.mission_model(id) | ||
| on delete cascade, | ||
| constraint mdg_derivation_group_exists | ||
| foreign key (derivation_group_name) | ||
| references merlin.derivation_group(name) | ||
| on update cascade | ||
| on delete restrict | ||
| ); | ||
|
|
||
| comment on table merlin.model_derivation_group is e'' | ||
| 'The default set of derivation groups that any new plans created using this model would have linked to them.'; | ||
|
|
||
| comment on column merlin.model_derivation_group.model_id is e'' | ||
| 'The model with which the derivation group is associated.'; | ||
| comment on column merlin.model_derivation_group.derivation_group_name is e'' | ||
| 'The derivation group being associated with the model.'; |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.