The best way to control Claude Code, Codex and more from any computer or phone

main
ts 62 lines 2.29 KB
Raw
1 #!/usr/bin/env -S node
2 import { Migration, MigrationCLI, col, fn, primaryKey } from "@prisma/orm-postgres/migration";
3 import type { Contract as End } from "../../snapshots/f32b3c3cf6335c4b528aa6d8233d0d9ffa0a87cd175963c0b6665ccebcf99793/contract";
4 import endContract from "../../snapshots/f32b3c3cf6335c4b528aa6d8233d0d9ffa0a87cd175963c0b6665ccebcf99793/contract.json" with { type: "json" };
5
6 export default class M extends Migration<never, End> {
7 override readonly endContractJson = endContract;
8
9 override get operations() {
10 return [
11 this.createSchema({ schema: "public" }),
12 this.createTable({
13 schema: "public",
14 table: "post",
15 columns: [
16 col("createdAt", "timestamptz", {
17 notNull: true,
18 default: fn("now()"),
19 codecRef: { codecId: "pg/timestamptz-temporal@1" },
20 }),
21 col("excerpt", "text", { notNull: true, codecRef: { codecId: "pg/text@1" } }),
22 col("id", "text", { notNull: true, codecRef: { codecId: "pg/text@1" } }),
23 col("title", "text", { notNull: true, codecRef: { codecId: "pg/text@1" } }),
24 col("userId", "text", { notNull: true, codecRef: { codecId: "pg/text@1" } }),
25 ],
26 constraints: [primaryKey(["id"])],
27 }),
28 this.createTable({
29 schema: "public",
30 table: "user",
31 columns: [
32 col("createdAt", "timestamptz", {
33 notNull: true,
34 default: fn("now()"),
35 codecRef: { codecId: "pg/timestamptz-temporal@1" },
36 }),
37 col("email", "text", { notNull: true, codecRef: { codecId: "pg/text@1" } }),
38 col("id", "text", { notNull: true, codecRef: { codecId: "pg/text@1" } }),
39 col("name", "text", { notNull: true, codecRef: { codecId: "pg/text@1" } }),
40 ],
41 constraints: [primaryKey(["id"])],
42 }),
43 this.createIndex({
44 schema: "public",
45 table: "post",
46 index: "post_userId_idx_a489d58a",
47 columns: ["userId"],
48 }),
49 this.addForeignKey({
50 schema: "public",
51 table: "post",
52 foreignKey: {
53 name: "post_userId_fkey",
54 columns: ["userId"],
55 references: { schema: "public", table: "user", columns: ["id"] },
56 },
57 }),
58 ];
59 }
60 }
61
62 MigrationCLI.run(import.meta.url, M);