import "org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg"

tableName() ::= "subscriptions"

tableFields(prefix) ::= <<
  <prefix>bundle_id
, <prefix>category
, <prefix>start_date
, <prefix>bundle_start_date
, <prefix>charged_through_date
, <prefix>migrated
, <prefix>created_by
, <prefix>created_date
, <prefix>updated_by
, <prefix>updated_date
>>

tableValues() ::= <<
  :bundleId
, :category
, :startDate
, :bundleStartDate
, :chargedThroughDate
, :migrated
, :createdBy
, :createdDate
, :updatedBy
, :updatedDate
>>


getSubscriptionsFromBundleId() ::= <<
select
<allTableFields("")>
from <tableName()>
where bundle_id = :bundleId
<AND_CHECK_TENANT("")>
<defaultOrderBy("")>
;
>>

updateChargedThroughDate() ::= <<
update <tableName()>
set
charged_through_date = :chargedThroughDate
, updated_by = :createdBy
, updated_date = :updatedDate
where id = :id
<AND_CHECK_TENANT("")>
;
>>
