SELECT $2;
$$ LANGUAGE SQL;
+CREATE OR REPLACE FUNCTION is_tt2( TEXT ) RETURNS BOOL AS $func$
+use strict;
+use warnings;
+
+use Template;
+use Template::Context;
+
+my $text = shift;
+my $result = Template::Context->new->template(\$text);
+if (defined $result) {
+ return 1;
+} else {
+ warn Template->error;
+ return 0;
+}
+$func$ LANGUAGE plperlu;
+
+
CREATE OR REPLACE FUNCTION is_json( TEXT ) RETURNS BOOL AS $f$
use JSON::XS;
my $json = shift();
opt_in_setting TEXT REFERENCES config.usr_setting_type (name) DEFERRABLE INITIALLY DEFERRED,
delay_field TEXT, -- for instance, xact_start on a circ hook ... look for fields on hook.core_type where datatype=timestamp? If not set, delay from now()
group_field TEXT, -- field from this.hook.core_type to batch event targets together on, fed into reactor a group at a time.
- template TEXT, -- the TT block. will have an 'environment' hash (or array of hashes, grouped events) built up by validator and collector(s), which can be modified.
+ template TEXT CHECK ( is_tt2 (template) ), -- the TT block. will have an 'environment' hash (or array of hashes, grouped events) built up by validator and collector(s), which can be modified.
granularity TEXT, -- could specify a batch which is the only time these events should actually run
CONSTRAINT ev_def_owner_hook_val_react_clean_delay_once UNIQUE (owner, hook, validator, reactor, delay, delay_field),
CONSTRAINT ev_def_name_owner_once UNIQUE (owner, name)
--- /dev/null
+BEGIN;
+
+-- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+CREATE OR REPLACE FUNCTION is_tt2( TEXT ) RETURNS BOOL AS $func$
+use strict;
+use warnings;
+
+use Template;
+use Template::Context;
+
+my $text = shift;
+my $result = Template::Context->new->template(\$text);
+if (defined $result) {
+ return 1;
+} else {
+ warn Template->error;
+ return 0;
+}
+$func$ LANGUAGE plperlu;
+
+
+ALTER TABLE action_trigger.event_definition
+ ADD CONSTRAINT template_is_tt2 CHECK ( is_tt2 (template) );
+
+COMMIT;