diff --git a/deployment/hasura/metadata/databases/tables/merlin/mission_model.yaml b/deployment/hasura/metadata/databases/tables/merlin/mission_model.yaml index 64969023ea..fe689dc6bf 100644 --- a/deployment/hasura/metadata/databases/tables/merlin/mission_model.yaml +++ b/deployment/hasura/metadata/databases/tables/merlin/mission_model.yaml @@ -4,110 +4,113 @@ table: configuration: custom_name: "mission_model" object_relationships: -- name: parameters - using: - foreign_key_constraint_on: - column: model_id - table: - name: mission_model_parameters - schema: merlin -- name: uploaded_file - using: - foreign_key_constraint_on: jar_id + - name: parameters + using: + foreign_key_constraint_on: + column: model_id + table: + name: mission_model_parameters + schema: merlin + - name: uploaded_file + using: + foreign_key_constraint_on: jar_id + - name: view + using: + foreign_key_constraint_on: default_view_id array_relationships: -- name: activity_types - using: - foreign_key_constraint_on: - column: model_id - table: - name: activity_type - schema: merlin -- name: constraint_specification - using: - foreign_key_constraint_on: - column: model_id - table: - name: constraint_model_specification - schema: merlin -- name: plans - using: - foreign_key_constraint_on: - column: model_id - table: - name: plan - schema: merlin -- name: resource_types - using: - foreign_key_constraint_on: - column: model_id - table: - name: resource_type - schema: merlin -- name: scheduling_specification_conditions - using: - foreign_key_constraint_on: - column: model_id - table: - name: scheduling_model_specification_conditions - schema: scheduler -- name: scheduling_specification_goals - using: - foreign_key_constraint_on: - column: model_id - table: - name: scheduling_model_specification_goals - schema: scheduler -- name: refresh_activity_type_logs - using: - manual_configuration: - remote_table: - name: refresh_activity_type_logs - schema: hasura - column_mapping: - id: model_id -- name: refresh_model_parameter_logs - using: - manual_configuration: - remote_table: - name: refresh_model_parameter_logs - schema: hasura - column_mapping: - id: model_id -- name: refresh_resource_type_logs - using: - manual_configuration: - remote_table: - name: refresh_resource_type_logs - schema: hasura - column_mapping: - id: model_id + - name: activity_types + using: + foreign_key_constraint_on: + column: model_id + table: + name: activity_type + schema: merlin + - name: constraint_specification + using: + foreign_key_constraint_on: + column: model_id + table: + name: constraint_model_specification + schema: merlin + - name: plans + using: + foreign_key_constraint_on: + column: model_id + table: + name: plan + schema: merlin + - name: resource_types + using: + foreign_key_constraint_on: + column: model_id + table: + name: resource_type + schema: merlin + - name: scheduling_specification_conditions + using: + foreign_key_constraint_on: + column: model_id + table: + name: scheduling_model_specification_conditions + schema: scheduler + - name: scheduling_specification_goals + using: + foreign_key_constraint_on: + column: model_id + table: + name: scheduling_model_specification_goals + schema: scheduler + - name: refresh_activity_type_logs + using: + manual_configuration: + remote_table: + name: refresh_activity_type_logs + schema: hasura + column_mapping: + id: model_id + - name: refresh_model_parameter_logs + using: + manual_configuration: + remote_table: + name: refresh_model_parameter_logs + schema: hasura + column_mapping: + id: model_id + - name: refresh_resource_type_logs + using: + manual_configuration: + remote_table: + name: refresh_resource_type_logs + schema: hasura + column_mapping: + id: model_id select_permissions: - role: aerie_admin permission: - columns: '*' + columns: "*" filter: {} allow_aggregations: true - role: user permission: - columns: '*' + columns: "*" filter: {} allow_aggregations: true - role: viewer permission: - columns: '*' + columns: "*" filter: {} allow_aggregations: true insert_permissions: - role: aerie_admin permission: - columns: [mission, name, version, description, jar_id] + columns: [mission, name, version, description, jar_id, default_view_id] check: {} set: - owner: 'x-hasura-user-id' + owner: "x-hasura-user-id" update_permissions: - role: aerie_admin permission: - columns: [mission, name, version, description, owner] + columns: [mission, name, version, description, owner, default_view_id] filter: {} delete_permissions: - role: aerie_admin @@ -115,54 +118,54 @@ delete_permissions: filter: {} event_triggers: -- definition: - enable_manual: false - insert: - columns: "*" - update: - columns: - - id - - revision - - jar_id - - mission - - name - - version - - owner - name: refreshActivityTypes - retry_conf: - interval_sec: 10 - num_retries: 0 - timeout_sec: 300 - webhook: "{{AERIE_MERLIN_URL}}/refreshActivityTypes" -- definition: - enable_manual: false - insert: - columns: "*" - update: - columns: - - id - - revision - - jar_id - - mission - - name - - version - - owner - name: refreshModelParameters - retry_conf: - interval_sec: 10 - num_retries: 0 - timeout_sec: 300 - webhook: "{{AERIE_MERLIN_URL}}/refreshModelParameters" -- definition: - enable_manual: false - insert: - columns: "*" - update: - columns: - - jar_id - name: refreshResourceTypes - retry_conf: - interval_sec: 10 - num_retries: 0 - timeout_sec: 300 - webhook: "{{AERIE_MERLIN_URL}}/refreshResourceTypes" + - definition: + enable_manual: false + insert: + columns: "*" + update: + columns: + - id + - revision + - jar_id + - mission + - name + - version + - owner + name: refreshActivityTypes + retry_conf: + interval_sec: 10 + num_retries: 0 + timeout_sec: 300 + webhook: "{{AERIE_MERLIN_URL}}/refreshActivityTypes" + - definition: + enable_manual: false + insert: + columns: "*" + update: + columns: + - id + - revision + - jar_id + - mission + - name + - version + - owner + name: refreshModelParameters + retry_conf: + interval_sec: 10 + num_retries: 0 + timeout_sec: 300 + webhook: "{{AERIE_MERLIN_URL}}/refreshModelParameters" + - definition: + enable_manual: false + insert: + columns: "*" + update: + columns: + - jar_id + name: refreshResourceTypes + retry_conf: + interval_sec: 10 + num_retries: 0 + timeout_sec: 300 + webhook: "{{AERIE_MERLIN_URL}}/refreshResourceTypes" diff --git a/deployment/hasura/migrations/Aerie/4_mission_model_default_view/down.sql b/deployment/hasura/migrations/Aerie/4_mission_model_default_view/down.sql new file mode 100644 index 0000000000..1762b65d4d --- /dev/null +++ b/deployment/hasura/migrations/Aerie/4_mission_model_default_view/down.sql @@ -0,0 +1,4 @@ +alter table merlin.mission_model + drop column default_view_id; + +call migrations.mark_migration_rolled_back('4'); diff --git a/deployment/hasura/migrations/Aerie/4_mission_model_default_view/up.sql b/deployment/hasura/migrations/Aerie/4_mission_model_default_view/up.sql new file mode 100644 index 0000000000..742977bf58 --- /dev/null +++ b/deployment/hasura/migrations/Aerie/4_mission_model_default_view/up.sql @@ -0,0 +1,11 @@ +alter table merlin.mission_model + add column default_view_id integer default null, + + add foreign key (default_view_id) + references ui.view (id) + on delete set null; + +comment on column merlin.mission_model.default_view_id is e'' + 'The ID of an option default view for the mission model.'; + +call migrations.mark_migration_applied('4'); diff --git a/deployment/postgres-init-db/sql/applied_migrations.sql b/deployment/postgres-init-db/sql/applied_migrations.sql index 27cacb7e06..f9c845e577 100644 --- a/deployment/postgres-init-db/sql/applied_migrations.sql +++ b/deployment/postgres-init-db/sql/applied_migrations.sql @@ -6,3 +6,4 @@ call migrations.mark_migration_applied('0'); call migrations.mark_migration_applied('1'); call migrations.mark_migration_applied('2'); call migrations.mark_migration_applied('3'); +call migrations.mark_migration_applied('4'); diff --git a/deployment/postgres-init-db/sql/init.sql b/deployment/postgres-init-db/sql/init.sql index 175c0ffba7..a42a30c46b 100644 --- a/deployment/postgres-init-db/sql/init.sql +++ b/deployment/postgres-init-db/sql/init.sql @@ -24,6 +24,9 @@ begin; \ir tables/tags/tags.sql \ir functions/tags/get_tags.sql + -- UI + \ir init_ui.sql + -- Merlin \ir init_merlin.sql @@ -33,9 +36,6 @@ begin; -- Sequencing \ir init_sequencing.sql - -- UI - \ir init_ui.sql - -- Tags \ir init_tags.sql diff --git a/deployment/postgres-init-db/sql/tables/merlin/mission_model.sql b/deployment/postgres-init-db/sql/tables/merlin/mission_model.sql index 34b936e84f..5e6108fc9b 100644 --- a/deployment/postgres-init-db/sql/tables/merlin/mission_model.sql +++ b/deployment/postgres-init-db/sql/tables/merlin/mission_model.sql @@ -6,6 +6,7 @@ create table merlin.mission_model ( name text not null, version text not null, description text not null default '', + default_view_id integer default null, owner text, jar_id integer not null, @@ -24,6 +25,9 @@ create table merlin.mission_model ( constraint mission_model_owner_exists foreign key (owner) references permissions.users on update cascade + on delete set null, + foreign key (default_view_id) + references ui.view on delete set null ); @@ -48,6 +52,8 @@ comment on column merlin.mission_model.created_at is e'' 'The time this mission model was uploaded into Aerie.'; comment on column merlin.mission_model.description is e'' 'A human-meaningful description of the mission model.'; +comment on column merlin.mission_model.default_view_id is e'' + 'The ID of an optional default view for the mission model.'; create trigger increment_revision_mission_model_update before update on merlin.mission_model