import type { Knex } from "knex" export async function up(knex: Knex): Promise { await knex.schema.createTable("users", function (table) { table.increments("id").notNullable().primary() table.string("email", 100).notNullable() table.string("auth0_subject", 100).notNullable() table.string("first_name", 100).notNullable() table.string("last_name", 100).notNullable() table.string("display_name", 200).notNullable() table.string("roles", 255).notNullable() table .specificType("created_at", "TIMESTAMP WITH TIME ZONE") .notNullable() .defaultTo(knex.raw("CURRENT_TIMESTAMP(0)")) table .specificType("updated_at", "TIMESTAMP WITH TIME ZONE") .notNullable() .defaultTo(knex.raw("CURRENT_TIMESTAMP(0)")) table.specificType("deleted_at", "TIMESTAMP WITH TIME ZONE") table.unique(["email"], { indexName: "users_email_unique", predicate: knex.whereNull("deleted_at"), }) table.unique(["auth0_subject"], { indexName: "users_auth0_subject_unique", predicate: knex.whereNull("deleted_at"), }) }) } export async function down(knex: Knex): Promise { await knex.schema.dropTable("users") }