group BusinessSubscriptionTransitionField;

CHECK_TENANT() ::= "tenant_record_id = :tenantRecordId"
AND_CHECK_TENANT() ::= "AND <CHECK_TENANT()>"

getFieldsForBusinessSubscriptionTransitionByKey(external_key) ::=<<
select
  bundle_id
, external_key
, account_key
, name
, value
, tenant_record_id
from bst_fields
where external_key = :external_key
<AND_CHECK_TENANT()>
;
>>

addField(bundle_id, external_key, name, value) ::=<<
insert into bst_fields (
  bundle_id
, external_key
, account_key
, name
, value
, account_record_id
, tenant_record_id
) values (
  :bundle_id
, :external_key
, :account_key
, :name
, :value
, :accountRecordId
, :tenantRecordId
);
>>

removeField(bundle_id, name) ::= <<
delete from bst_fields where bundle_id = :bundle_id and name = :name <AND_CHECK_TENANT()>;
>>

test() ::= <<
select 1 from bst_fields where <CHECK_TENANT()> limit 1;
>>
