This commit is contained in:
ntr
2019-06-28 16:08:55 +10:00
parent e6486dc361
commit 4921b0760c
10 changed files with 342 additions and 69 deletions
@@ -2,14 +2,29 @@ exports.up = async knex => {
return knex.schema.createTable('accounts', table => {
table.uuid('id').primary();
table.timestamps(true, true);
table.string('name', 42).notNullable().unique();
table.string('password').notNullable();
table.string('token', 64).notNullable();
table.timestamp('token_expiry').notNullable();
table.bigInteger('credits')
.defaultTo(0)
.notNullable();
table.bool('subscribed')
.defaultTo(false)
.notNullable();
table.index('name');
table.index('id');
});
await knex.schema.raw(`
ALTER TABLE accounts
ADD CHECK (credits > 0);
`);
};
exports.down = async () => {};
+9 -6
View File
@@ -4,7 +4,7 @@
exports.up = async knex => {
await knex.schema.createTable('stripe_customers', table => {
table.string('customer', 64)
table.string('customer', 128)
.primary();
table.uuid('account')
@@ -16,7 +16,7 @@ exports.up = async knex => {
.inTable('accounts')
.onDelete('RESTRICT');
table.string('checkout', 64)
table.string('checkout', 128)
.notNullable()
.unique();
@@ -24,7 +24,7 @@ exports.up = async knex => {
});
await knex.schema.createTable('stripe_subscriptions', table => {
table.string('subscription', 64)
table.string('subscription', 128)
.primary();
table.uuid('account')
@@ -36,14 +36,17 @@ exports.up = async knex => {
.inTable('accounts')
.onDelete('RESTRICT');
table.string('customer', 64)
table.string('customer', 128)
.notNullable();
table.string('checkout', 128)
.notNullable();
table.timestamps(true, true);
});
await knex.schema.createTable('stripe_purchases', table => {
table.string('checkout', 64)
table.string('checkout', 128)
.primary();
table.uuid('account')
@@ -55,7 +58,7 @@ exports.up = async knex => {
.inTable('accounts')
.onDelete('RESTRICT');
table.string('customer', 64)
table.string('customer', 128)
.notNullable();
table.bigInteger('amount')