Skip to content

Commit

Permalink
Merge pull request #304 from NASA-AMMOS/feat/user-sequence
Browse files Browse the repository at this point in the history
[AERIE-1982] feat: add user sequence table
  • Loading branch information
camargo authored Aug 31, 2022
2 parents 1d7c43a + 785d76b commit f78ae0d
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions command-expansion-server/sql/commanding/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ begin;
\ir tables/activity_instance_commands.sql
\ir tables/sequence.sql
\ir tables/sequence_to_simulated_activity.sql
\ir tables/user_sequence.sql

end;
39 changes: 39 additions & 0 deletions command-expansion-server/sql/commanding/tables/user_sequence.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
create table user_sequence (
authoring_command_dict_id integer not null,
created_at timestamptz not null default now(),
definition text not null,
id integer generated always as identity,
name text not null,
owner text not null default 'unknown',
updated_at timestamptz not null default now(),

constraint user_sequence_primary_key primary key (id)
);

comment on column user_sequence.authoring_command_dict_id is e''
'Command dictionary the user sequence was created with.';
comment on column user_sequence.created_at is e''
'Time the user sequence was created.';
comment on column user_sequence.definition is e''
'The user sequence definition string.';
comment on column user_sequence.id is e''
'ID of the user sequence.';
comment on column user_sequence.name is e''
'Human-readable name of the user sequence.';
comment on column user_sequence.owner is e''
'Username of the user sequence owner.';
comment on column user_sequence.updated_at is e''
'Time the user sequence was last updated.';

create or replace function user_sequence_set_updated_at()
returns trigger
security definer
language plpgsql as $$begin
new.updated_at = now();
return new;
end$$;

create trigger set_timestamp
before update on user_sequence
for each row
execute function user_sequence_set_updated_at();
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
table:
name: user_sequence
schema: public
object_relationships:
- name: command_dictionary
using:
manual_configuration:
remote_table:
schema: public
name: command_dictionary
insertion_order: null
column_mapping:
authoring_command_dict_id: id
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
- "!include public_rule_expansion_set_view.yaml"
- "!include public_sequence.yaml"
- "!include public_sequence_to_simulated_activity.yaml"
- "!include public_user_sequence.yaml"

0 comments on commit f78ae0d

Please sign in to comment.