~singpolyma/jmp-pay

b4988c12f406e7c02d3e18f45899d930e268b42a — Stephen Paul Weber 1 year, 3 months ago 1acc55b
Update schema and INSERT to plan_log using new range type

plan_log has been updated to use a range type, so our INSERTs need to be
updated as well.
4 files changed, 7 insertions(+), 6 deletions(-)

M bin/billing_monthly_cronjob
M bin/process_pending_btc_transactions
M config.ru
M schemas
M bin/billing_monthly_cronjob => bin/billing_monthly_cronjob +3 -2
@@ 101,8 101,9 @@ class Plan

		params = [RENEW_UNTIL, customer_id, expires_at]
		db.exec_params(<<-SQL, params)
		  UPDATE plan_log SET expires_at=$1
		  WHERE customer_id=$2 AND expires_at=$3
			UPDATE plan_log
			SET date_range=range_merge(date_range, tsrange('now', $1))
			WHERE customer_id=$2 AND date_range -|- tsrange($3, $3, '[]')
		SQL
	end
end

M bin/process_pending_btc_transactions => bin/process_pending_btc_transactions +2 -2
@@ 122,9 122,9 @@ class Plan
		params = [@customer.id, name, start, expire]
		DB.exec_params(<<-SQL, params)
			INSERT INTO plan_log
				(customer_id, plan_name, starts_at, expires_at)
				(customer_id, plan_name, date_range)
			VALUES
				($1, $2, $3, $4)
				($1, $2, tsrange($3, $4))
		SQL
	end


M config.ru => config.ru +1 -1
@@ 63,7 63,7 @@ class Plan

	def activate(customer_id, months)
		DB.exec_params(
			"INSERT INTO plan_log VALUES ($1, $2, $3, $4)",
			"INSERT INTO plan_log VALUES ($1, $2, tsrange($3, $4))",
			[customer_id, @plan[:name], Time.now, Date.today >> months]
		)
		true

M schemas => schemas +1 -1
@@ 1,1 1,1 @@
Subproject commit 3e0d7e8ae7193f567294036c3235d50ed318b945
Subproject commit 5573078307ccb4fed4dec6e95a2bf38e91385424