34 lines
779 B
JavaScript
Executable File
34 lines
779 B
JavaScript
Executable File
exports.up = async knex => {
|
|
await 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()
|
|
.index();
|
|
|
|
table.timestamp('token_expiry').notNullable();
|
|
|
|
table.bigInteger('balance')
|
|
.defaultTo(0)
|
|
.notNullable();
|
|
|
|
table.bool('subscribed')
|
|
.defaultTo(false)
|
|
.notNullable();
|
|
|
|
table.index('name');
|
|
});
|
|
|
|
await knex.schema.raw(`
|
|
ALTER TABLE accounts
|
|
ADD CHECK (balance >= 0);
|
|
`);
|
|
|
|
return true;
|
|
};
|
|
|
|
exports.down = async () => {}; |