ducky/subscriptions

Paddy 2015-09-30 Parent:61c4ce5850da

15:aab6ba5ae392 Go to Latest

ducky/subscriptions/sql/postgres_init.sql

Log Postgres test failures more verbosely, fix SubscriptionChange.IsEmpty. SubscriptionChange.IsEmpty() would return false even if no actual database operations are going to be performed. This is because we allow information we _don't_ store in the database (Stripe source, Stripe email) to be specified in a SubscriptionChange object, just so we can easily access them. Then we use the Stripe API to store them in Stripe's databases, and turn them into data _we_ store in our database. Think of them as pre-processed values that are never stored raw. The problem is, we were treating these properties the same as the properties we actually stored in the database, and (worse) were running database tests for combinations of these properties, which was causing test failures because we were trying to update no columns in the database. Whoops. I removed these properties from the IsEmpty helper, and removed them from the code that generates the SubscriptionChange permutations for testing. This allows tests to pass, but also stays closer to what the system was designed to do. In tracking down this bug, I discovered that the logging we had for errors when running Postgres tests was inadequate, so I updated the logs when that failure occurs while testing Postgres to help surface future failures faster.

History
1 CREATE TABLE IF NOT EXISTS subscriptions (
2 user_id VARCHAR(36) PRIMARY KEY,
3 stripe_subscription VARCHAR(36) UNIQUE NOT NULL,
4 plan VARCHAR(36) NOT NULL,
5 status VARCHAR(16) NOT NULL,
6 canceling BOOLEAN NOT NULL,
7 created TIMESTAMPTZ NOT NULL,
8 trial_start TIMESTAMPTZ NOT NULL,
9 trial_end TIMESTAMPTZ NOT NULL,
10 period_start TIMESTAMPTZ NOT NULL,
11 period_end TIMESTAMPTZ NOT NULL,
12 canceled_at TIMESTAMPTZ NOT NULL,
13 failed_charge_attempts INTEGER NOT NULL,
14 last_failed_charge TIMESTAMPTZ NOT NULL,
15 last_notified TIMESTAMPTZ NOT NULL
16 );