Kysely & Deno postgres
Created: 1 2023,Updated: 1 2023,(0) fork,(0) stars,(0) comments,
How to create migrations
First create migrations path with file schema below
import { Kysely, sql } from "https://esm.sh/kysely@0.22.0";
export async function up(db: Kysely<unknown>) {
await db.schema
.createTable("users")
.ifNotExists()
.addColumn(
"id",
"uuid",
(col) => col.primaryKey().defaultTo(sql`gen_random_uuid()`),
)
.addColumn("email", "varchar(256)", (col) => col.notNull().unique())
.addColumn("emailVerified", "timestamp")
.addColumn("password", "varchar(256)")
.addColumn("avatarUrl", "varchar(256)")
.execute();
}
export async function down(db: Kysely<unknown>) {
await db.schema.dropTable("users").ifExists().execute();
}