@@ -12,22 +12,45 @@ create table sequencing.sequence_template (
12
12
13
13
constraint sequence_template_pkey primary key (id),
14
14
constraint activity_type foreign key (activity_type, model_id)
15
- references merlin .activity_type (name, model_id) match simple
15
+ references merlin .activity_type (name, model_id)
16
16
on update cascade
17
17
on delete set null ,
18
- constraint " model_id -> merlin.mission_model.id " foreign key (model_id)
19
- references merlin .mission_model (id) match simple
18
+ constraint seq_template_mission_model_exists foreign key (model_id)
19
+ references merlin .mission_model (id)
20
20
on update cascade
21
21
on delete set null ,
22
- constraint " parcel_id -> sequencing.parcel.id " foreign key (parcel_id)
23
- references sequencing .parcel (id) match simple
22
+ constraint seq_template_parcel_exists foreign key (parcel_id)
23
+ references sequencing .parcel (id)
24
24
on update cascade
25
25
on delete set null ,
26
26
27
27
constraint only_one_template_per_model_activity_type
28
- unique (model_id, activity_type)
28
+ unique (model_id, activity_type)
29
29
);
30
30
31
+ comment on table sequencing.sequence_template is e' '
32
+ ' A table of sequence templates for given activity types.' ;
33
+
34
+ comment on column sequencing.sequence_template.id is e' '
35
+ ' The unique integer id for this sequence template.' ;
36
+ comment on column sequencing.sequence_template.name is e' '
37
+ ' The user-provided name for this template.' ;
38
+ comment on column sequencing.sequence_template.model_id is e' '
39
+ ' The mission model id that this template applies to.\n '
40
+ ' This id is used in correlating this template with a real activity type.' ;
41
+ comment on column sequencing.sequence_template.parcel_id is e' '
42
+ ' The parcel that this template uses.\n '
43
+ ' This id is used to define available commands for this template.' ;
44
+ comment on column sequencing.sequence_template.template_definition is e' '
45
+ ' The actual, text definition for this template.\n '
46
+ ' Text should be formatted as Handlebars/Mustache-compliant text.' ;
47
+ comment on column sequencing.sequence_template.activity_type is e' '
48
+ ' The activity type that this sequence template applies to.' ;
49
+ comment on column sequencing.sequence_template.language is e' '
50
+ ' The language (STOL, SeqN) that this sequence template is written in.' ;
51
+ comment on column sequencing.sequence_template.owner is e' '
52
+ ' The user that created this sequence template.' ;
53
+
31
54
32
55
-- introduce sequence filters
33
56
create table sequencing .sequence_filter (
@@ -36,15 +59,29 @@ create table sequencing.sequence_filter (
36
59
model_id integer not null ,
37
60
name text ,
38
61
39
- constraint sequence_filter_primary_key
40
- primary key (id),
62
+ constraint sequence_filter_primary_key primary key (id),
41
63
42
- foreign key (model_id)
64
+ constraint seq_filter_mission_model_exists foreign key (model_id)
43
65
references merlin .mission_model
44
66
on update cascade
45
67
on delete cascade
46
68
);
47
69
70
+ comment on table sequencing.sequence_filter is e' '
71
+ ' A table of sequence filters, which select the appropriate\n '
72
+ ' simulated activity instances for a given sequence.' ;
73
+
74
+ comment on column sequencing.sequence_filter.id is e' '
75
+ ' The unique integer id for this sequence filter.' ;
76
+ comment on column sequencing.sequence_filter.filter is e' '
77
+ ' The JSON-formatted filter over the simulated activities that\n '
78
+ ' is used to select the appropriate simulated activity instances for a given sequence.' ;
79
+ comment on column sequencing.sequence_filter.model_id is e' '
80
+ ' The mission model that this filter applies to.\n '
81
+ ' This contextualizes the filter.' ;
82
+ comment on column sequencing.sequence_filter.name is e' '
83
+ ' The name of the sequence filter.' ;
84
+
48
85
49
86
-- introduce a table to hold the result of expanded templates, in a separate table from expanded sequences because
50
87
-- this result is in text, not necessarily jsonb.
@@ -66,13 +103,27 @@ create table sequencing.expanded_templates (
66
103
on delete cascade ,
67
104
68
105
constraint expanded_template_to_sequence
69
- foreign key (seq_id, simulation_dataset_id)
70
- references sequencing .sequence
71
- on delete cascade
106
+ foreign key (seq_id, simulation_dataset_id)
107
+ references sequencing .sequence
108
+ on delete cascade
72
109
);
73
110
74
111
comment on table sequencing.expanded_templates is e' '
75
112
' A cache of sequences that have already been expanded.' ;
76
113
114
+ comment on column sequencing.expanded_templates.id is e' '
115
+ ' The integer-generated unique id for an expanded template.' ;
116
+ comment on column sequencing.expanded_templates.seq_id is e' '
117
+ ' The id of the sequence that this expansion correlates with.\n '
118
+ ' That sequence is what correlates this template with the activities it expands.' ;
119
+ comment on column sequencing.expanded_templates.simulation_dataset_id is e' '
120
+ ' The id of the simulation that this expansion correlates with.\n '
121
+ ' This id tells us for what exact simulation run of a given plan (and therefore for what\n '
122
+ ' simulated activity entries) this expansion covers.' ;
123
+ comment on column sequencing.expanded_templates.expanded_template is e' '
124
+ ' The content of the expanded template.' ;
125
+ comment on column sequencing.expanded_templates.created_at is e' '
126
+ ' A temporal identifier that indicates when exactly this sequence was expanded.' ;
127
+
77
128
78
129
call migrations .mark_migration_applied (' 14' );
0 commit comments