it works, time to break it

This commit is contained in:
ntr
2019-06-24 21:38:30 +10:00
parent 3c085aa52b
commit 440554dc35
9 changed files with 373 additions and 167 deletions
+73
View File
@@ -0,0 +1,73 @@
// INSERT into stripe_customers (account, customer, checkout)
// INSERT into stripe_subscriptions (account, customer, checkout, subscription)
// INSERT into stripe_purchases (account, customer, checkout, amount)
exports.up = async knex => {
await knex.schema.createTable('stripe_customers', table => {
table.string('customer', 64)
.primary();
table.uuid('account')
.notNullable()
.index();
table.foreign('account')
.references('id')
.inTable('accounts')
.onDelete('RESTRICT');
table.string('checkout', 64)
.notNullable()
.unique();
table.timestamps(true, true);
});
await knex.schema.createTable('stripe_subscriptions', table => {
table.string('subscription', 64)
.primary();
table.uuid('account')
.notNullable()
.index();
table.foreign('account')
.references('id')
.inTable('accounts')
.onDelete('RESTRICT');
table.string('customer', 64)
.notNullable();
table.timestamps(true, true);
});
await knex.schema.createTable('stripe_purchases', table => {
table.string('checkout', 64)
.primary();
table.uuid('account')
.notNullable()
.index();
table.foreign('account')
.references('id')
.inTable('accounts')
.onDelete('RESTRICT');
table.string('customer', 64)
.notNullable();
table.bigInteger('amount')
.notNullable();
table.timestamps(true, true);
});
await knex.schema.raw(`
ALTER TABLE stripe_purchases
ADD CHECK (amount > 0);
`);
};
exports.down = async () => {};