Skip to content

Commit

Permalink
Merge pull request #1147 from NASA-AMMOS/feat/add-snapshot-tags-descr…
Browse files Browse the repository at this point in the history
…iption

Add Snapshot Tags, Description
  • Loading branch information
Mythicaeda authored Sep 19, 2023
2 parents 9168a86 + a52dd6b commit 66404a8
Show file tree
Hide file tree
Showing 11 changed files with 127 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
table:
name: plan_snapshot_tags
schema: metadata
configuration:
custom_name: "plan_snapshot_tags"
object_relationships:
- name: plan_snapshot
using:
foreign_key_constraint_on: snapshot_id
- name: tag
using:
foreign_key_constraint_on: tag_id
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: [snapshot_id, tag_id]
check: {}
- role: user
permission:
columns: [snapshot_id, tag_id]
check: {"plan_snapshot":{"plan":{"_or":[
{"owner":{"_eq":"X-Hasura-User-Id"}},
{"collaborators":{"collaborator":{"_eq":"X-Hasura-User-Id"}}}]}}}
delete_permissions:
- role: aerie_admin
permission:
filter: {}
- role: user
permission:
filter: {"plan_snapshot":{"plan":{"_or":[
{"owner":{"_eq":"X-Hasura-User-Id"}},
{"collaborators":{"collaborator":{"_eq":"X-Hasura-User-Id"}}}]}}}
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ insert_permissions:
update_permissions:
- role: aerie_admin
permission:
columns: [name, owner, duration, model_id, parent_id, start_time]
columns: [name, owner, duration, model_id, parent_id, start_time, description]
filter: {}
set:
updated_by: "x-hasura-user-id"
- role: user
permission:
columns: [name, owner]
columns: [name, owner, description]
filter: {"owner":{"_eq":"X-Hasura-User-Id"}}
set:
updated_by: "x-hasura-user-id"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ object_relationships:
remote_table:
name: plan
schema: public
array_relationships:
- name: activities
using:
foreign_key_constraint_on:
column: snapshot_id
table:
name: plan_snapshot_activities
schema: public
- name: tags
using:
foreign_key_constraint_on:
column: snapshot_id
table:
name: plan_snapshot_tags
schema: metadata
select_permissions:
- role: aerie_admin
permission:
Expand All @@ -27,6 +42,17 @@ select_permissions:
columns: '*'
filter: {}
allow_aggregations: true
update_permissions:
- role: aerie_admin
permission:
columns: [description, taken_by]
filter: {}
- role: user
permission:
columns: [description]
filter: {"plan":{"_or":[
{"owner":{"_eq":"X-Hasura-User-Id"}},
{"collaborators":{"collaborator":{"_eq":"X-Hasura-User-Id"}}}]}}
delete_permissions:
- role: aerie_admin
permission:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
- "!include metadata/tags.yaml"
- "!include metadata/activity_directive_tags.yaml"
- "!include metadata/constraint_tags.yaml"
- "!include metadata/plan_snapshot_tags.yaml"
- "!include metadata/plan_tags.yaml"
- "!include metadata/snapshot_activity_tags.yaml"
- "!include metadata/users_allowed_roles.yaml"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
drop table metadata.plan_snapshot_tags;
alter table plan_snapshot drop column description;
alter table plan drop column description;

call migrations.mark_migration_rolled_back('27');
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
alter table plan
add column description text;
comment on column plan.description is e''
'A human-readable description for this plan and its contents.';

alter table plan_snapshot
add column description text;
comment on column plan_snapshot.description is e''
'A human-readable description of the snapshot and its contents.';

create table metadata.plan_snapshot_tags(
snapshot_id integer not null references public.plan_snapshot
on update cascade
on delete cascade,
tag_id integer not null references metadata.tags
on update cascade
on delete cascade,
primary key (snapshot_id, tag_id)
);
comment on table metadata.plan_snapshot_tags is e''
'The tags associated with a specific. Note: these tags will not be compared in a merge '
'and will not be applied to the plan if the snapshot is restored.';

call migrations.mark_migration_applied('27');
1 change: 1 addition & 0 deletions merlin-server/sql/merlin/applied_migrations.sql
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ call migrations.mark_migration_applied('23');
call migrations.mark_migration_applied('24');
call migrations.mark_migration_applied('25');
call migrations.mark_migration_applied('26');
call migrations.mark_migration_applied('27');
1 change: 1 addition & 0 deletions merlin-server/sql/merlin/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ begin;
-- Table-specific Metadata
\ir tables/metadata/activity_directive_tags.sql
\ir tables/metadata/constraint_tags.sql
\ir tables/metadata/plan_snapshot_tags.sql
\ir tables/metadata/plan_tags.sql
\ir tables/metadata/snapshot_activity_tags.sql

Expand Down
13 changes: 13 additions & 0 deletions merlin-server/sql/merlin/tables/metadata/plan_snapshot_tags.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
create table metadata.plan_snapshot_tags(
snapshot_id integer not null references public.plan_snapshot
on update cascade
on delete cascade,
tag_id integer not null references metadata.tags
on update cascade
on delete cascade,
primary key (snapshot_id, tag_id)
);

comment on table metadata.plan_snapshot_tags is e''
'The tags associated with a specific. Note: these tags will not be compared in a merge '
'and will not be applied to the plan if the snapshot is restored.';
3 changes: 3 additions & 0 deletions merlin-server/sql/merlin/tables/plan.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ create table plan (

owner text,
updated_by text,
description text,

constraint plan_synthetic_key
primary key (id),
Expand Down Expand Up @@ -72,6 +73,8 @@ comment on column plan.owner is e''
'The user who owns the plan.';
comment on column plan.updated_by is e''
'The user who last updated the plan.';
comment on column plan.description is e''
'A human-readable description for this plan and its contents.';


create function increment_revision_on_update_plan()
Expand Down
3 changes: 3 additions & 0 deletions merlin-server/sql/merlin/tables/plan_snapshot.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ create table plan_snapshot(
revision integer not null,

snapshot_name text,
description text,
taken_by text,
taken_at timestamptz not null default now(),
constraint snapshot_name_unique_per_plan
Expand All @@ -27,6 +28,8 @@ comment on column plan_snapshot.revision is e''
'The revision of the plan at the time the snapshot was taken.';
comment on column plan_snapshot.snapshot_name is e''
'A human-readable name for the snapshot.';
comment on column plan_snapshot.description is e''
'A human-readable description of the snapshot and its contents.';
comment on column plan_snapshot.taken_by is e''
'The user who took the snapshot.';
comment on column plan_snapshot.taken_at is e''
Expand Down

0 comments on commit 66404a8

Please sign in to comment.