week5-node-express-knex-pg/db/migrations/20241021123023_create_users_table.cjs
Jeannette Chin 58f45f8947 first commit
2024-10-21 17:09:40 +01:00

22 lines
574 B
JavaScript

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.up = function (knex) {
return knex.schema.createTable("users", (table) => {
table.increments("id");
table.string("firstname", 50).notNullable().defaultTo("");
table.string("lastname", 50).notNullable().defaultTo("");
table.string("email", 100).notNullable().defaultTo("");
table.timestamps(true, true);
});
};
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.down = function (knex) {
return knex.schema.dropTable("users");
};