it works, time to break it
This commit is contained in:
@@ -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 () => {};
|
||||
Reference in New Issue
Block a user