@beignet/cli 0.0.8 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +68 -67
  3. package/dist/choices.d.ts +32 -3
  4. package/dist/choices.d.ts.map +1 -1
  5. package/dist/choices.js +54 -3
  6. package/dist/choices.js.map +1 -1
  7. package/dist/create-prompts.d.ts +5 -4
  8. package/dist/create-prompts.d.ts.map +1 -1
  9. package/dist/create-prompts.js +22 -4
  10. package/dist/create-prompts.js.map +1 -1
  11. package/dist/create.d.ts +7 -1
  12. package/dist/create.d.ts.map +1 -1
  13. package/dist/create.js +14 -4
  14. package/dist/create.js.map +1 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +25 -6
  17. package/dist/index.js.map +1 -1
  18. package/dist/inspect.js +78 -12
  19. package/dist/inspect.js.map +1 -1
  20. package/dist/make.d.ts +21 -1
  21. package/dist/make.d.ts.map +1 -1
  22. package/dist/make.js +210 -37
  23. package/dist/make.js.map +1 -1
  24. package/dist/templates/base.d.ts.map +1 -1
  25. package/dist/templates/base.js +80 -10
  26. package/dist/templates/base.js.map +1 -1
  27. package/dist/templates/db/index.d.ts +21 -0
  28. package/dist/templates/db/index.d.ts.map +1 -0
  29. package/dist/templates/db/index.js +14 -0
  30. package/dist/templates/db/index.js.map +1 -0
  31. package/dist/templates/db/mysql.d.ts +4 -0
  32. package/dist/templates/db/mysql.d.ts.map +1 -0
  33. package/dist/templates/db/mysql.js +972 -0
  34. package/dist/templates/db/mysql.js.map +1 -0
  35. package/dist/templates/db/postgres.d.ts +4 -0
  36. package/dist/templates/db/postgres.d.ts.map +1 -0
  37. package/dist/templates/db/postgres.js +863 -0
  38. package/dist/templates/db/postgres.js.map +1 -0
  39. package/dist/templates/db/sqlite.d.ts +3 -0
  40. package/dist/templates/db/sqlite.d.ts.map +1 -0
  41. package/dist/templates/db/sqlite.js +878 -0
  42. package/dist/templates/db/sqlite.js.map +1 -0
  43. package/dist/templates/db.js +16 -16
  44. package/dist/templates/index.d.ts +5 -5
  45. package/dist/templates/index.d.ts.map +1 -1
  46. package/dist/templates/index.js +21 -20
  47. package/dist/templates/index.js.map +1 -1
  48. package/dist/templates/server.d.ts +3 -3
  49. package/dist/templates/server.d.ts.map +1 -1
  50. package/dist/templates/server.js +149 -97
  51. package/dist/templates/server.js.map +1 -1
  52. package/dist/templates/shared.d.ts +34 -1
  53. package/dist/templates/shared.d.ts.map +1 -1
  54. package/dist/templates/shared.js +45 -0
  55. package/dist/templates/shared.js.map +1 -1
  56. package/package.json +2 -2
  57. package/src/choices.ts +70 -3
  58. package/src/create-prompts.ts +25 -3
  59. package/src/create.ts +25 -3
  60. package/src/index.ts +29 -5
  61. package/src/inspect.ts +137 -19
  62. package/src/make.ts +265 -34
  63. package/src/templates/base.ts +96 -10
  64. package/src/templates/db/index.ts +34 -0
  65. package/src/templates/db/mysql.ts +976 -0
  66. package/src/templates/db/postgres.ts +867 -0
  67. package/src/templates/{db.ts → db/sqlite.ts} +47 -168
  68. package/src/templates/index.ts +24 -19
  69. package/src/templates/server.ts +161 -97
  70. package/src/templates/shared.ts +90 -1
@@ -0,0 +1,867 @@
1
+ // The starter ships its initial Drizzle migration inside the template so the
2
+ // first run is `db migrate` with no generate step. `dbSchema` and the
3
+ // `starterMigration*` files below pair together — regenerate together.
4
+ //
5
+ // To regenerate: scaffold a scratch app with `dbSchema` as
6
+ // infra/db/schema/index.ts plus `drizzleConfig` as drizzle.config.ts, run
7
+ // `drizzle-kit generate --name starter` with the drizzle-kit version pinned in
8
+ // externalVersions (no Postgres server needed; generate diffs the schema
9
+ // against an empty snapshot), paste drizzle/0000_starter.sql,
10
+ // drizzle/meta/_journal.json, and drizzle/meta/0000_snapshot.json back here
11
+ // verbatim, then append the output of
12
+ // createDrizzlePostgresIdempotencySetupStatements() from
13
+ // @beignet/provider-db-drizzle/postgres to the migration SQL, separated by
14
+ // `--> statement-breakpoint`. The idempotency table is provider-owned and
15
+ // lives outside the app schema, so `db generate` never diffs against it.
16
+ //
17
+ // The Better Auth tables were generated with
18
+ // `bunx @better-auth/cli generate` against a scratch app configured with
19
+ // drizzleAdapter(db, { provider: "pg" }), then normalized to the starter's
20
+ // conventions (tabs, no relations, no extra indexes, no column defaults).
21
+
22
+ import { databaseLocalUrl } from "../../choices.js";
23
+ import type { TemplateContext } from "../shared.js";
24
+ import type { DbTemplateFiles } from "./index.js";
25
+
26
+ export function postgresDbFiles(ctx: TemplateContext): DbTemplateFiles {
27
+ return {
28
+ drizzleConfig: `export default {
29
+ schema: "./infra/db/schema/index.ts",
30
+ out: "./drizzle",
31
+ dialect: "postgresql",
32
+ dbCredentials: {
33
+ url: process.env.POSTGRES_DB_URL ?? "${databaseLocalUrl("postgres", ctx.name)}",
34
+ },
35
+ };
36
+ `,
37
+ dbSchema: `import { boolean, index, pgTable, text, timestamp } from "drizzle-orm/pg-core";
38
+
39
+ export const user = pgTable("user", {
40
+ id: text("id").primaryKey(),
41
+ name: text("name").notNull(),
42
+ email: text("email").notNull().unique(),
43
+ emailVerified: boolean("email_verified").notNull().default(false),
44
+ image: text("image"),
45
+ createdAt: timestamp("created_at").notNull(),
46
+ updatedAt: timestamp("updated_at").notNull(),
47
+ });
48
+
49
+ export const session = pgTable("session", {
50
+ id: text("id").primaryKey(),
51
+ expiresAt: timestamp("expires_at").notNull(),
52
+ token: text("token").notNull().unique(),
53
+ createdAt: timestamp("created_at").notNull(),
54
+ updatedAt: timestamp("updated_at").notNull(),
55
+ ipAddress: text("ip_address"),
56
+ userAgent: text("user_agent"),
57
+ userId: text("user_id")
58
+ .notNull()
59
+ .references(() => user.id, { onDelete: "cascade" }),
60
+ });
61
+
62
+ export const account = pgTable("account", {
63
+ id: text("id").primaryKey(),
64
+ accountId: text("account_id").notNull(),
65
+ providerId: text("provider_id").notNull(),
66
+ userId: text("user_id")
67
+ .notNull()
68
+ .references(() => user.id, { onDelete: "cascade" }),
69
+ accessToken: text("access_token"),
70
+ refreshToken: text("refresh_token"),
71
+ idToken: text("id_token"),
72
+ accessTokenExpiresAt: timestamp("access_token_expires_at"),
73
+ refreshTokenExpiresAt: timestamp("refresh_token_expires_at"),
74
+ scope: text("scope"),
75
+ password: text("password"),
76
+ createdAt: timestamp("created_at").notNull(),
77
+ updatedAt: timestamp("updated_at").notNull(),
78
+ });
79
+
80
+ export const verification = pgTable("verification", {
81
+ id: text("id").primaryKey(),
82
+ identifier: text("identifier").notNull(),
83
+ value: text("value").notNull(),
84
+ expiresAt: timestamp("expires_at").notNull(),
85
+ createdAt: timestamp("created_at"),
86
+ updatedAt: timestamp("updated_at"),
87
+ });
88
+
89
+ export const todos = pgTable(
90
+ "todos",
91
+ {
92
+ id: text("id").primaryKey(),
93
+ userId: text("user_id")
94
+ .notNull()
95
+ .references(() => user.id, { onDelete: "cascade" }),
96
+ title: text("title").notNull(),
97
+ completed: boolean("completed").notNull().default(false),
98
+ // Kept as an ISO-8601 text column on purpose: TodoSchema validates
99
+ // createdAt with z.string().datetime(), repositories pass rows through
100
+ // unmapped, and list ordering compares the strings lexicographically.
101
+ createdAt: text("created_at").notNull(),
102
+ },
103
+ (table) => ({
104
+ userIdx: index("todos_user_idx").on(table.userId, table.createdAt),
105
+ }),
106
+ );
107
+ `,
108
+ drizzleTodoRepository: `import type { beignetServerOnly } from "@beignet/core/server-only";
109
+ import { offsetPageResult } from "@beignet/core/pagination";
110
+ import type { DrizzlePostgresDatabase } from "@beignet/provider-db-drizzle/postgres";
111
+ import { count, desc, eq } from "drizzle-orm";
112
+ import type {
113
+ NewTodo,
114
+ TodoRepository,
115
+ UpdateTodoData,
116
+ } from "@/features/todos/ports";
117
+ import type { Todo } from "@/features/todos/schemas";
118
+ import * as schema from "@/infra/db/schema";
119
+
120
+ type TodoRow = typeof schema.todos.$inferSelect;
121
+
122
+ function toTodo(row: TodoRow): Todo {
123
+ return {
124
+ id: row.id,
125
+ userId: row.userId,
126
+ title: row.title,
127
+ completed: row.completed,
128
+ createdAt: row.createdAt,
129
+ };
130
+ }
131
+
132
+ export function createDrizzleTodoRepository(
133
+ db: DrizzlePostgresDatabase<typeof schema>,
134
+ ): TodoRepository {
135
+ return {
136
+ async list(userId, page) {
137
+ const rows = await db
138
+ .select()
139
+ .from(schema.todos)
140
+ .where(eq(schema.todos.userId, userId))
141
+ .orderBy(desc(schema.todos.createdAt))
142
+ .limit(page.limit)
143
+ .offset(page.offset);
144
+ const [{ total }] = await db
145
+ .select({ total: count() })
146
+ .from(schema.todos)
147
+ .where(eq(schema.todos.userId, userId));
148
+
149
+ return offsetPageResult(rows.map(toTodo), page, total);
150
+ },
151
+ async findById(id: string) {
152
+ const [row] = await db
153
+ .select()
154
+ .from(schema.todos)
155
+ .where(eq(schema.todos.id, id))
156
+ .limit(1);
157
+
158
+ return row ? toTodo(row) : null;
159
+ },
160
+ async create(input: NewTodo) {
161
+ const todo = {
162
+ id: crypto.randomUUID(),
163
+ userId: input.userId,
164
+ title: input.title,
165
+ completed: false,
166
+ createdAt: new Date().toISOString(),
167
+ };
168
+ const [row] = await db.insert(schema.todos).values(todo).returning();
169
+
170
+ if (!row) {
171
+ throw new Error("Failed to create todo");
172
+ }
173
+
174
+ return toTodo(row);
175
+ },
176
+ async update(id: string, input: UpdateTodoData) {
177
+ const [row] = await db
178
+ .update(schema.todos)
179
+ .set({ completed: input.completed })
180
+ .where(eq(schema.todos.id, id))
181
+ .returning();
182
+
183
+ if (!row) {
184
+ throw new Error(\`Failed to update todo \${id}\`);
185
+ }
186
+
187
+ return toTodo(row);
188
+ },
189
+ async delete(id: string) {
190
+ await db.delete(schema.todos).where(eq(schema.todos.id, id));
191
+ },
192
+ };
193
+ }
194
+ `,
195
+ dbRepositories: `import type { DrizzlePostgresDatabase } from "@beignet/provider-db-drizzle/postgres";
196
+ import { createDrizzleTodoRepository } from "@/infra/todos/drizzle-todo-repository";
197
+ import type { AppTransactionPorts } from "@/ports";
198
+ import * as schema from "./schema";
199
+
200
+ export function createRepositories(
201
+ db: DrizzlePostgresDatabase<typeof schema>,
202
+ ): Omit<AppTransactionPorts, "idempotency"> {
203
+ return {
204
+ todos: createDrizzleTodoRepository(db),
205
+ };
206
+ }
207
+ `,
208
+ databaseReady: `import { drizzle } from "drizzle-orm/node-postgres";
209
+ import { migrate } from "drizzle-orm/node-postgres/migrator";
210
+ import type { Pool } from "pg";
211
+
212
+ let ready: Promise<void> | undefined;
213
+
214
+ /**
215
+ * Make sure the database is usable before the first query runs.
216
+ *
217
+ * In development, pending migrations from \`drizzle/\` are applied
218
+ * automatically so a fresh clone works without remembering
219
+ * \`beignet db migrate\`. In production the schema is never mutated;
220
+ * an unmigrated database fails loudly with the command to run.
221
+ *
222
+ * Memoized per process so Next.js page-data workers that reach this in
223
+ * parallel share one preparation pass.
224
+ */
225
+ export function ensureDatabaseReady(pool: Pool): Promise<void> {
226
+ ready ??= prepare(pool);
227
+ return ready;
228
+ }
229
+
230
+ async function prepare(pool: Pool): Promise<void> {
231
+ if (process.env.NODE_ENV === "production") {
232
+ const tables = await pool.query(
233
+ "SELECT table_name FROM information_schema.tables WHERE table_schema = current_schema() AND table_name = 'user' LIMIT 1",
234
+ );
235
+ if (tables.rows.length === 0) {
236
+ throw new Error(
237
+ "Database has no tables yet. Run \`beignet db migrate\` against this database before starting the app.",
238
+ );
239
+ }
240
+ return;
241
+ }
242
+
243
+ await migrate(drizzle(pool), { migrationsFolder: "drizzle" });
244
+ }
245
+ `,
246
+ dbProvider: `import type { beignetServerOnly } from "@beignet/core/server-only";
247
+ import { createProvider } from "@beignet/core/providers";
248
+ import {
249
+ createDrizzlePostgresIdempotencyPort,
250
+ createDrizzlePostgresUnitOfWork,
251
+ type DbPort,
252
+ } from "@beignet/provider-db-drizzle/postgres";
253
+ import type { AppPorts } from "@/ports";
254
+ import { ensureDatabaseReady } from "./database-ready";
255
+ import { createRepositories } from "./repositories";
256
+ import type * as schema from "./schema";
257
+
258
+ export const starterDatabaseProvider = createProvider<{
259
+ db: DbPort<typeof schema>;
260
+ }>()({
261
+ name: "starter-database",
262
+
263
+ async setup({ ports }) {
264
+ const dbPort = ports.db;
265
+ if (!dbPort) {
266
+ throw new Error(
267
+ "starterDatabaseProvider requires a db port. Register createDrizzlePostgresProvider({ schema }) before it.",
268
+ );
269
+ }
270
+
271
+ const repositories = createRepositories(dbPort.db);
272
+ const idempotency = createDrizzlePostgresIdempotencyPort(dbPort.db);
273
+
274
+ const providedPorts: Pick<AppPorts, "idempotency" | "todos" | "uow"> = {
275
+ ...repositories,
276
+ idempotency,
277
+ uow: createDrizzlePostgresUnitOfWork({
278
+ db: dbPort.db,
279
+ createTransactionPorts: (tx) => ({
280
+ ...createRepositories(tx),
281
+ idempotency: createDrizzlePostgresIdempotencyPort(tx),
282
+ }),
283
+ }),
284
+ };
285
+
286
+ return {
287
+ ports: providedPorts,
288
+ async start() {
289
+ await ensureDatabaseReady(dbPort.pool);
290
+ },
291
+ };
292
+ },
293
+ });
294
+ `,
295
+ dbReset: `import { drizzle } from "drizzle-orm/node-postgres";
296
+ import { migrate } from "drizzle-orm/node-postgres/migrator";
297
+ import pg from "pg";
298
+ import { env } from "@/lib/env";
299
+
300
+ const host = new URL(env.POSTGRES_DB_URL).hostname;
301
+ if (
302
+ host !== "localhost" &&
303
+ host !== "127.0.0.1" &&
304
+ process.env.BEIGNET_ALLOW_DATABASE_RESET !== "true"
305
+ ) {
306
+ throw new Error(
307
+ "Refusing to reset a non-local database. Set BEIGNET_ALLOW_DATABASE_RESET=true if this is intentional.",
308
+ );
309
+ }
310
+
311
+ const tables = [
312
+ "verification",
313
+ "account",
314
+ "session",
315
+ "todos",
316
+ "user",
317
+ "idempotency_records",
318
+ ] as const;
319
+
320
+ const pool = new pg.Pool({ connectionString: env.POSTGRES_DB_URL });
321
+
322
+ try {
323
+ for (const table of tables) {
324
+ await pool.query(\`DROP TABLE IF EXISTS "\${table}" CASCADE\`);
325
+ }
326
+ // drizzle-kit and the runtime migrator track applied migrations in the
327
+ // "drizzle" schema, so drop it to replay the checked-in migrations.
328
+ await pool.query('DROP SCHEMA IF EXISTS "drizzle" CASCADE');
329
+
330
+ await migrate(drizzle(pool), { migrationsFolder: "drizzle" });
331
+ console.log("Database reset.");
332
+ } finally {
333
+ await pool.end();
334
+ }
335
+ `,
336
+ dbTestDatabase: `import { PGlite } from "@electric-sql/pglite";
337
+ import { drizzle, type PgliteDatabase } from "drizzle-orm/pglite";
338
+ import { migrate } from "drizzle-orm/pglite/migrator";
339
+ import { createRepositories } from "./repositories";
340
+ import * as schema from "./schema";
341
+
342
+ export type TestDatabase = {
343
+ client: PGlite;
344
+ db: PgliteDatabase<typeof schema>;
345
+ repositories: ReturnType<typeof createRepositories>;
346
+ close(): Promise<void>;
347
+ };
348
+
349
+ /**
350
+ * In-process Postgres for tests, backed by PGlite — no server required.
351
+ * PGlite's drizzle instance satisfies the same Postgres database seam the
352
+ * app repositories use. Better Auth is not exercised through this helper;
353
+ * it connects through the pg pool in lib/better-auth.
354
+ */
355
+ export async function createTestDatabase(): Promise<TestDatabase> {
356
+ const client = new PGlite();
357
+ const db = drizzle(client, { schema });
358
+ await migrate(db, { migrationsFolder: "drizzle" });
359
+
360
+ return {
361
+ client,
362
+ db,
363
+ repositories: createRepositories(db),
364
+ close: async () => {
365
+ await client.close();
366
+ },
367
+ };
368
+ }
369
+ `,
370
+ ...postgresStarterMigration,
371
+ };
372
+ }
373
+
374
+ const postgresStarterMigration = {
375
+ // Generated by drizzle-kit generate --name starter against dbSchema
376
+ // above, with the provider idempotency setup statements appended.
377
+ starterMigrationSql: `CREATE TABLE "account" (
378
+ "id" text PRIMARY KEY NOT NULL,
379
+ "account_id" text NOT NULL,
380
+ "provider_id" text NOT NULL,
381
+ "user_id" text NOT NULL,
382
+ "access_token" text,
383
+ "refresh_token" text,
384
+ "id_token" text,
385
+ "access_token_expires_at" timestamp,
386
+ "refresh_token_expires_at" timestamp,
387
+ "scope" text,
388
+ "password" text,
389
+ "created_at" timestamp NOT NULL,
390
+ "updated_at" timestamp NOT NULL
391
+ );
392
+ --> statement-breakpoint
393
+ CREATE TABLE "session" (
394
+ "id" text PRIMARY KEY NOT NULL,
395
+ "expires_at" timestamp NOT NULL,
396
+ "token" text NOT NULL,
397
+ "created_at" timestamp NOT NULL,
398
+ "updated_at" timestamp NOT NULL,
399
+ "ip_address" text,
400
+ "user_agent" text,
401
+ "user_id" text NOT NULL,
402
+ CONSTRAINT "session_token_unique" UNIQUE("token")
403
+ );
404
+ --> statement-breakpoint
405
+ CREATE TABLE "todos" (
406
+ "id" text PRIMARY KEY NOT NULL,
407
+ "user_id" text NOT NULL,
408
+ "title" text NOT NULL,
409
+ "completed" boolean DEFAULT false NOT NULL,
410
+ "created_at" text NOT NULL
411
+ );
412
+ --> statement-breakpoint
413
+ CREATE TABLE "user" (
414
+ "id" text PRIMARY KEY NOT NULL,
415
+ "name" text NOT NULL,
416
+ "email" text NOT NULL,
417
+ "email_verified" boolean DEFAULT false NOT NULL,
418
+ "image" text,
419
+ "created_at" timestamp NOT NULL,
420
+ "updated_at" timestamp NOT NULL,
421
+ CONSTRAINT "user_email_unique" UNIQUE("email")
422
+ );
423
+ --> statement-breakpoint
424
+ CREATE TABLE "verification" (
425
+ "id" text PRIMARY KEY NOT NULL,
426
+ "identifier" text NOT NULL,
427
+ "value" text NOT NULL,
428
+ "expires_at" timestamp NOT NULL,
429
+ "created_at" timestamp,
430
+ "updated_at" timestamp
431
+ );
432
+ --> statement-breakpoint
433
+ ALTER TABLE "account" ADD CONSTRAINT "account_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
434
+ ALTER TABLE "session" ADD CONSTRAINT "session_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
435
+ ALTER TABLE "todos" ADD CONSTRAINT "todos_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
436
+ CREATE INDEX "todos_user_idx" ON "todos" USING btree ("user_id","created_at");
437
+ --> statement-breakpoint
438
+ CREATE TABLE IF NOT EXISTS "idempotency_records" (
439
+ storage_key text PRIMARY KEY NOT NULL,
440
+ namespace text NOT NULL,
441
+ idempotency_key text NOT NULL,
442
+ scope_key text NOT NULL,
443
+ fingerprint text NOT NULL,
444
+ status text NOT NULL,
445
+ result_json text,
446
+ reserved_at text NOT NULL,
447
+ completed_at text,
448
+ expires_at text,
449
+ updated_at text NOT NULL
450
+ );--> statement-breakpoint
451
+ CREATE INDEX IF NOT EXISTS "idempotency_records_lookup_idx" ON "idempotency_records" (namespace, scope_key, idempotency_key);--> statement-breakpoint
452
+ CREATE INDEX IF NOT EXISTS "idempotency_records_expires_idx" ON "idempotency_records" (expires_at);
453
+ `,
454
+ starterMigrationJournal: `{
455
+ "version": "7",
456
+ "dialect": "postgresql",
457
+ "entries": [
458
+ {
459
+ "idx": 0,
460
+ "version": "7",
461
+ "when": 1781285555823,
462
+ "tag": "0000_starter",
463
+ "breakpoints": true
464
+ }
465
+ ]
466
+ }`,
467
+ starterMigrationSnapshot: `{
468
+ "id": "33cd3ae7-5014-401d-abb0-a1eb69055b7e",
469
+ "prevId": "00000000-0000-0000-0000-000000000000",
470
+ "version": "7",
471
+ "dialect": "postgresql",
472
+ "tables": {
473
+ "public.account": {
474
+ "name": "account",
475
+ "schema": "",
476
+ "columns": {
477
+ "id": {
478
+ "name": "id",
479
+ "type": "text",
480
+ "primaryKey": true,
481
+ "notNull": true
482
+ },
483
+ "account_id": {
484
+ "name": "account_id",
485
+ "type": "text",
486
+ "primaryKey": false,
487
+ "notNull": true
488
+ },
489
+ "provider_id": {
490
+ "name": "provider_id",
491
+ "type": "text",
492
+ "primaryKey": false,
493
+ "notNull": true
494
+ },
495
+ "user_id": {
496
+ "name": "user_id",
497
+ "type": "text",
498
+ "primaryKey": false,
499
+ "notNull": true
500
+ },
501
+ "access_token": {
502
+ "name": "access_token",
503
+ "type": "text",
504
+ "primaryKey": false,
505
+ "notNull": false
506
+ },
507
+ "refresh_token": {
508
+ "name": "refresh_token",
509
+ "type": "text",
510
+ "primaryKey": false,
511
+ "notNull": false
512
+ },
513
+ "id_token": {
514
+ "name": "id_token",
515
+ "type": "text",
516
+ "primaryKey": false,
517
+ "notNull": false
518
+ },
519
+ "access_token_expires_at": {
520
+ "name": "access_token_expires_at",
521
+ "type": "timestamp",
522
+ "primaryKey": false,
523
+ "notNull": false
524
+ },
525
+ "refresh_token_expires_at": {
526
+ "name": "refresh_token_expires_at",
527
+ "type": "timestamp",
528
+ "primaryKey": false,
529
+ "notNull": false
530
+ },
531
+ "scope": {
532
+ "name": "scope",
533
+ "type": "text",
534
+ "primaryKey": false,
535
+ "notNull": false
536
+ },
537
+ "password": {
538
+ "name": "password",
539
+ "type": "text",
540
+ "primaryKey": false,
541
+ "notNull": false
542
+ },
543
+ "created_at": {
544
+ "name": "created_at",
545
+ "type": "timestamp",
546
+ "primaryKey": false,
547
+ "notNull": true
548
+ },
549
+ "updated_at": {
550
+ "name": "updated_at",
551
+ "type": "timestamp",
552
+ "primaryKey": false,
553
+ "notNull": true
554
+ }
555
+ },
556
+ "indexes": {},
557
+ "foreignKeys": {
558
+ "account_user_id_user_id_fk": {
559
+ "name": "account_user_id_user_id_fk",
560
+ "tableFrom": "account",
561
+ "tableTo": "user",
562
+ "columnsFrom": [
563
+ "user_id"
564
+ ],
565
+ "columnsTo": [
566
+ "id"
567
+ ],
568
+ "onDelete": "cascade",
569
+ "onUpdate": "no action"
570
+ }
571
+ },
572
+ "compositePrimaryKeys": {},
573
+ "uniqueConstraints": {},
574
+ "policies": {},
575
+ "checkConstraints": {},
576
+ "isRLSEnabled": false
577
+ },
578
+ "public.session": {
579
+ "name": "session",
580
+ "schema": "",
581
+ "columns": {
582
+ "id": {
583
+ "name": "id",
584
+ "type": "text",
585
+ "primaryKey": true,
586
+ "notNull": true
587
+ },
588
+ "expires_at": {
589
+ "name": "expires_at",
590
+ "type": "timestamp",
591
+ "primaryKey": false,
592
+ "notNull": true
593
+ },
594
+ "token": {
595
+ "name": "token",
596
+ "type": "text",
597
+ "primaryKey": false,
598
+ "notNull": true
599
+ },
600
+ "created_at": {
601
+ "name": "created_at",
602
+ "type": "timestamp",
603
+ "primaryKey": false,
604
+ "notNull": true
605
+ },
606
+ "updated_at": {
607
+ "name": "updated_at",
608
+ "type": "timestamp",
609
+ "primaryKey": false,
610
+ "notNull": true
611
+ },
612
+ "ip_address": {
613
+ "name": "ip_address",
614
+ "type": "text",
615
+ "primaryKey": false,
616
+ "notNull": false
617
+ },
618
+ "user_agent": {
619
+ "name": "user_agent",
620
+ "type": "text",
621
+ "primaryKey": false,
622
+ "notNull": false
623
+ },
624
+ "user_id": {
625
+ "name": "user_id",
626
+ "type": "text",
627
+ "primaryKey": false,
628
+ "notNull": true
629
+ }
630
+ },
631
+ "indexes": {},
632
+ "foreignKeys": {
633
+ "session_user_id_user_id_fk": {
634
+ "name": "session_user_id_user_id_fk",
635
+ "tableFrom": "session",
636
+ "tableTo": "user",
637
+ "columnsFrom": [
638
+ "user_id"
639
+ ],
640
+ "columnsTo": [
641
+ "id"
642
+ ],
643
+ "onDelete": "cascade",
644
+ "onUpdate": "no action"
645
+ }
646
+ },
647
+ "compositePrimaryKeys": {},
648
+ "uniqueConstraints": {
649
+ "session_token_unique": {
650
+ "name": "session_token_unique",
651
+ "nullsNotDistinct": false,
652
+ "columns": [
653
+ "token"
654
+ ]
655
+ }
656
+ },
657
+ "policies": {},
658
+ "checkConstraints": {},
659
+ "isRLSEnabled": false
660
+ },
661
+ "public.todos": {
662
+ "name": "todos",
663
+ "schema": "",
664
+ "columns": {
665
+ "id": {
666
+ "name": "id",
667
+ "type": "text",
668
+ "primaryKey": true,
669
+ "notNull": true
670
+ },
671
+ "user_id": {
672
+ "name": "user_id",
673
+ "type": "text",
674
+ "primaryKey": false,
675
+ "notNull": true
676
+ },
677
+ "title": {
678
+ "name": "title",
679
+ "type": "text",
680
+ "primaryKey": false,
681
+ "notNull": true
682
+ },
683
+ "completed": {
684
+ "name": "completed",
685
+ "type": "boolean",
686
+ "primaryKey": false,
687
+ "notNull": true,
688
+ "default": false
689
+ },
690
+ "created_at": {
691
+ "name": "created_at",
692
+ "type": "text",
693
+ "primaryKey": false,
694
+ "notNull": true
695
+ }
696
+ },
697
+ "indexes": {
698
+ "todos_user_idx": {
699
+ "name": "todos_user_idx",
700
+ "columns": [
701
+ {
702
+ "expression": "user_id",
703
+ "isExpression": false,
704
+ "asc": true,
705
+ "nulls": "last"
706
+ },
707
+ {
708
+ "expression": "created_at",
709
+ "isExpression": false,
710
+ "asc": true,
711
+ "nulls": "last"
712
+ }
713
+ ],
714
+ "isUnique": false,
715
+ "concurrently": false,
716
+ "method": "btree",
717
+ "with": {}
718
+ }
719
+ },
720
+ "foreignKeys": {
721
+ "todos_user_id_user_id_fk": {
722
+ "name": "todos_user_id_user_id_fk",
723
+ "tableFrom": "todos",
724
+ "tableTo": "user",
725
+ "columnsFrom": [
726
+ "user_id"
727
+ ],
728
+ "columnsTo": [
729
+ "id"
730
+ ],
731
+ "onDelete": "cascade",
732
+ "onUpdate": "no action"
733
+ }
734
+ },
735
+ "compositePrimaryKeys": {},
736
+ "uniqueConstraints": {},
737
+ "policies": {},
738
+ "checkConstraints": {},
739
+ "isRLSEnabled": false
740
+ },
741
+ "public.user": {
742
+ "name": "user",
743
+ "schema": "",
744
+ "columns": {
745
+ "id": {
746
+ "name": "id",
747
+ "type": "text",
748
+ "primaryKey": true,
749
+ "notNull": true
750
+ },
751
+ "name": {
752
+ "name": "name",
753
+ "type": "text",
754
+ "primaryKey": false,
755
+ "notNull": true
756
+ },
757
+ "email": {
758
+ "name": "email",
759
+ "type": "text",
760
+ "primaryKey": false,
761
+ "notNull": true
762
+ },
763
+ "email_verified": {
764
+ "name": "email_verified",
765
+ "type": "boolean",
766
+ "primaryKey": false,
767
+ "notNull": true,
768
+ "default": false
769
+ },
770
+ "image": {
771
+ "name": "image",
772
+ "type": "text",
773
+ "primaryKey": false,
774
+ "notNull": false
775
+ },
776
+ "created_at": {
777
+ "name": "created_at",
778
+ "type": "timestamp",
779
+ "primaryKey": false,
780
+ "notNull": true
781
+ },
782
+ "updated_at": {
783
+ "name": "updated_at",
784
+ "type": "timestamp",
785
+ "primaryKey": false,
786
+ "notNull": true
787
+ }
788
+ },
789
+ "indexes": {},
790
+ "foreignKeys": {},
791
+ "compositePrimaryKeys": {},
792
+ "uniqueConstraints": {
793
+ "user_email_unique": {
794
+ "name": "user_email_unique",
795
+ "nullsNotDistinct": false,
796
+ "columns": [
797
+ "email"
798
+ ]
799
+ }
800
+ },
801
+ "policies": {},
802
+ "checkConstraints": {},
803
+ "isRLSEnabled": false
804
+ },
805
+ "public.verification": {
806
+ "name": "verification",
807
+ "schema": "",
808
+ "columns": {
809
+ "id": {
810
+ "name": "id",
811
+ "type": "text",
812
+ "primaryKey": true,
813
+ "notNull": true
814
+ },
815
+ "identifier": {
816
+ "name": "identifier",
817
+ "type": "text",
818
+ "primaryKey": false,
819
+ "notNull": true
820
+ },
821
+ "value": {
822
+ "name": "value",
823
+ "type": "text",
824
+ "primaryKey": false,
825
+ "notNull": true
826
+ },
827
+ "expires_at": {
828
+ "name": "expires_at",
829
+ "type": "timestamp",
830
+ "primaryKey": false,
831
+ "notNull": true
832
+ },
833
+ "created_at": {
834
+ "name": "created_at",
835
+ "type": "timestamp",
836
+ "primaryKey": false,
837
+ "notNull": false
838
+ },
839
+ "updated_at": {
840
+ "name": "updated_at",
841
+ "type": "timestamp",
842
+ "primaryKey": false,
843
+ "notNull": false
844
+ }
845
+ },
846
+ "indexes": {},
847
+ "foreignKeys": {},
848
+ "compositePrimaryKeys": {},
849
+ "uniqueConstraints": {},
850
+ "policies": {},
851
+ "checkConstraints": {},
852
+ "isRLSEnabled": false
853
+ }
854
+ },
855
+ "enums": {},
856
+ "schemas": {},
857
+ "sequences": {},
858
+ "roles": {},
859
+ "policies": {},
860
+ "views": {},
861
+ "_meta": {
862
+ "columns": {},
863
+ "schemas": {},
864
+ "tables": {}
865
+ }
866
+ }`,
867
+ };