30 lines
753 B
JavaScript
Executable File
30 lines
753 B
JavaScript
Executable File
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 () => {}; |