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