2weekmail/api/db/migrations/20250318123324_user_table.js
2025-03-19 19:56:57 -05:00

26 lines
744 B
JavaScript

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.up = function(knex) {
return knex.schema.createTable('users', function(table) {
table.increments('id').primary();
table.string('username').notNullable();
table.string('email').notNullable();
table.string('password').notNullable();
table.boolean('is_admin').defaultTo(false);
table.boolean('is_active').defaultTo(true);
table.text('api_key').nullable();
table.datetime('created').defaultTo(knex.fn.now());
table.datetime('modified').defaultTo(knex.fn.now());
});
};
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.down = function(knex) {
return knex.schema.dropTable('users');
};