-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1526 from NASA-AMMOS/feature/sequence-workspaces
Added the backend for sequencing workspaces
- Loading branch information
Showing
9 changed files
with
193 additions
and
4 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
64 changes: 64 additions & 0 deletions
64
deployment/hasura/metadata/databases/tables/sequencing/workspace.yaml
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,64 @@ | ||
table: | ||
name: workspace | ||
schema: sequencing | ||
configuration: | ||
custom_name: "workspace" | ||
array_relationships: | ||
- name: user_sequences | ||
using: | ||
foreign_key_constraint_on: | ||
column: workspace_id | ||
table: | ||
name: user_sequence | ||
schema: sequencing | ||
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: [name, owner] | ||
check: {} | ||
set: | ||
owner: "x-hasura-user-id" | ||
updated_by: "x-hasura-user-id" | ||
- role: user | ||
permission: | ||
columns: [name, owner] | ||
check: {} | ||
set: | ||
owner: "x-hasura-user-id" | ||
updated_by: "x-hasura-user-id" | ||
update_permissions: | ||
- role: aerie_admin | ||
permission: | ||
columns: [name, owner] | ||
filter: {} | ||
set: | ||
updated_by: "x-hasura-user-id" | ||
- role: user | ||
permission: | ||
columns: [name, owner] | ||
filter: { "owner": { "_eq": "x-hasura-user-id" } } | ||
set: | ||
updated_by: "x-hasura-user-id" | ||
delete_permissions: | ||
- role: aerie_admin | ||
permission: | ||
filter: {} | ||
- role: user | ||
permission: | ||
filter: {"owner":{"_eq":"x-hasura-user-id"}} |
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
8 changes: 8 additions & 0 deletions
8
deployment/hasura/migrations/Aerie/9_sequence_workspaces/down.sql
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,8 @@ | ||
alter table sequencing.user_sequence | ||
drop constraint user_sequence_workspace_id_fkey, | ||
drop column workspace_id; | ||
|
||
drop trigger set_timestamp on sequencing.workspace; | ||
drop table sequencing.workspace; | ||
|
||
call migrations.mark_migration_rolled_back('9'); |
66 changes: 66 additions & 0 deletions
66
deployment/hasura/migrations/Aerie/9_sequence_workspaces/up.sql
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,66 @@ | ||
---- Add the new workspace table | ||
|
||
create table sequencing.workspace ( | ||
id integer generated always as identity, | ||
|
||
name text not null, | ||
|
||
created_at timestamptz not null default now(), | ||
owner text, | ||
updated_at timestamptz not null default now(), | ||
updated_by text, | ||
|
||
constraint workspace_synthetic_key | ||
primary key (id), | ||
foreign key (owner) | ||
references permissions.users | ||
on update cascade | ||
on delete set null, | ||
foreign key (updated_by) | ||
references permissions.users | ||
on update cascade | ||
on delete set null | ||
); | ||
|
||
comment on table sequencing.workspace is e'' | ||
'A container for multiple sequences.'; | ||
comment on column sequencing.workspace.name is e'' | ||
'The name of the workspace.'; | ||
comment on column sequencing.workspace.owner is e'' | ||
'The user responsible for this workspace.'; | ||
comment on column sequencing.workspace.created_at is e'' | ||
'Time the workspace was created at.'; | ||
comment on column sequencing.workspace.updated_at is e'' | ||
'Time the workspace was last updated.'; | ||
comment on column sequencing.workspace.updated_by is e'' | ||
'The user who last updated the workspace.'; | ||
|
||
create trigger set_timestamp | ||
before update on sequencing.workspace | ||
for each row | ||
execute function util_functions.set_updated_at(); | ||
|
||
---- Add the new workspace_id column to the user_sequence table | ||
|
||
alter table sequencing.user_sequence | ||
add column workspace_id integer, | ||
|
||
add foreign key (workspace_id) | ||
references sequencing.parcel (id) | ||
on delete cascade; | ||
|
||
comment on column sequencing.user_sequence.workspace_id is e'' | ||
'The workspace the sequence is associated with.'; | ||
|
||
---- Populate the workspace table with a default workspace to contain existing sequences | ||
|
||
insert into sequencing.workspace (name, owner) | ||
values ('Workspace 1', 'Aerie Legacy'); | ||
|
||
update sequencing.user_sequence | ||
set workspace_id = 1; | ||
|
||
alter table sequencing.user_sequence | ||
alter column workspace_id set not null; | ||
|
||
call migrations.mark_migration_applied('9'); |
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
39 changes: 39 additions & 0 deletions
39
deployment/postgres-init-db/sql/tables/sequencing/workspace.sql
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,39 @@ | ||
create table sequencing.workspace ( | ||
id integer generated always as identity, | ||
|
||
name text not null, | ||
|
||
created_at timestamptz not null default now(), | ||
owner text, | ||
updated_at timestamptz not null default now(), | ||
updated_by text, | ||
|
||
constraint workspace_synthetic_key | ||
primary key (id), | ||
foreign key (owner) | ||
references permissions.users | ||
on update cascade | ||
on delete set null, | ||
foreign key (updated_by) | ||
references permissions.users | ||
on update cascade | ||
on delete set null | ||
); | ||
|
||
comment on table sequencing.workspace is e'' | ||
'A container for multiple sequences.'; | ||
comment on column sequencing.workspace.name is e'' | ||
'The name of the workspace.'; | ||
comment on column sequencing.workspace.owner is e'' | ||
'The user responsible for this workspace.'; | ||
comment on column sequencing.workspace.created_at is e'' | ||
'Time the workspace was created at.'; | ||
comment on column sequencing.workspace.updated_at is e'' | ||
'Time the workspace was last updated.'; | ||
comment on column sequencing.workspace.updated_by is e'' | ||
'The user who last updated the workspace.'; | ||
|
||
create trigger set_timestamp | ||
before update on sequencing.workspace | ||
for each row | ||
execute function util_functions.set_updated_at(); |