d1-kyt 0.9.6 → 0.9.7
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/dist/cli.js +1 -1
- package/package.json +2 -1
- package/src/cli.ts +368 -0
- package/src/config.ts +18 -0
- package/src/executor.test.ts +324 -0
- package/src/executor.ts +214 -0
- package/src/index.ts +31 -0
- package/src/migrate.test.ts +438 -0
- package/src/migrate.ts +371 -0
- package/src/naming.test.ts +75 -0
- package/src/naming.ts +40 -0
- package/src/query-builder.test.ts +70 -0
- package/src/query-builder.ts +23 -0
- package/src/schema-diff.test.ts +963 -0
- package/src/schema-diff.ts +670 -0
- package/src/schema.test.ts +374 -0
- package/src/schema.ts +351 -0
- package/src/validators.test.ts +112 -0
- package/src/validators.ts +36 -0
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { dirname, join, resolve } from 'node:path';
|
|
4
|
-
const VERSION = '0.9.
|
|
4
|
+
const VERSION = '0.9.7';
|
|
5
5
|
const HELP = `
|
|
6
6
|
d1-kyt v${VERSION} - Opinionated Cloudflare D1 + Kysely toolkit
|
|
7
7
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "d1-kyt",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.7",
|
|
4
4
|
"description": "Opinionated Cloudflare D1 + Kysely toolkit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
22
|
"dist",
|
|
23
|
+
"src",
|
|
23
24
|
"skills"
|
|
24
25
|
],
|
|
25
26
|
"keywords": [
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { dirname, join, resolve } from 'node:path';
|
|
5
|
+
|
|
6
|
+
const VERSION = '0.9.7';
|
|
7
|
+
|
|
8
|
+
const HELP = `
|
|
9
|
+
d1-kyt v${VERSION} - Opinionated Cloudflare D1 + Kysely toolkit
|
|
10
|
+
|
|
11
|
+
Usage:
|
|
12
|
+
d1-kyt init [--dir <dir>]
|
|
13
|
+
d1-kyt schema:diff [name] [--dir <dir>] [--schema <path>]
|
|
14
|
+
|
|
15
|
+
Commands:
|
|
16
|
+
init Scaffold config, schema template, and snapshot in <dir>
|
|
17
|
+
schema:diff Diff schema against snapshot → generate .sql migration
|
|
18
|
+
|
|
19
|
+
Options:
|
|
20
|
+
--dir <path> Directory for config/schema/snapshot (default: auto-detected
|
|
21
|
+
from wrangler migrations_dir parent, or "db/")
|
|
22
|
+
--schema <path> Override schema file path (default: <dir>/schema.ts)
|
|
23
|
+
--help, -h Show this help message
|
|
24
|
+
--version, -v Show version
|
|
25
|
+
|
|
26
|
+
Examples:
|
|
27
|
+
d1-kyt init # auto-detect dir (db/ by default)
|
|
28
|
+
d1-kyt init --dir db # use db/config.ts, db/schema.ts, db/schema.json
|
|
29
|
+
d1-kyt schema:diff create_users
|
|
30
|
+
d1-kyt schema:diff # auto-derives name from diff
|
|
31
|
+
d1-kyt schema:diff add_idx --schema src/schema.ts
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
import type { D1KytConfig } from './config.js';
|
|
35
|
+
import { generateMigrationPrefix } from './naming.js';
|
|
36
|
+
import { serializeSchema, diffSnapshots, diffToSQL } from './schema-diff.js';
|
|
37
|
+
import type { SchemaSnapshot, SchemaDiff } from './schema-diff.js';
|
|
38
|
+
|
|
39
|
+
// ----------------------------------------------------------------------------
|
|
40
|
+
// Wrangler config
|
|
41
|
+
// ----------------------------------------------------------------------------
|
|
42
|
+
|
|
43
|
+
interface WranglerD1Config {
|
|
44
|
+
migrationsDir: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function readWranglerConfig(): WranglerD1Config | null {
|
|
48
|
+
const wranglerPaths = ['wrangler.jsonc', 'wrangler.json', 'wrangler.toml'];
|
|
49
|
+
|
|
50
|
+
for (const filename of wranglerPaths) {
|
|
51
|
+
const filepath = resolve(process.cwd(), filename);
|
|
52
|
+
if (!existsSync(filepath)) continue;
|
|
53
|
+
|
|
54
|
+
if (filename.endsWith('.toml')) {
|
|
55
|
+
const content = readFileSync(filepath, 'utf-8');
|
|
56
|
+
const match = content.match(/migrations_dir\s*=\s*"([^"]+)"/);
|
|
57
|
+
if (match) return { migrationsDir: match[1] };
|
|
58
|
+
} else {
|
|
59
|
+
const content = readFileSync(filepath, 'utf-8')
|
|
60
|
+
.replace(/\/\/.*$/gm, '')
|
|
61
|
+
.replace(/\/\*[\s\S]*?\*\//g, '');
|
|
62
|
+
try {
|
|
63
|
+
const cfg = JSON.parse(content);
|
|
64
|
+
const d1 = cfg.d1_databases?.[0];
|
|
65
|
+
if (d1?.migrations_dir) return { migrationsDir: d1.migrations_dir };
|
|
66
|
+
} catch {
|
|
67
|
+
// ignore
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// ----------------------------------------------------------------------------
|
|
75
|
+
// Dir resolution
|
|
76
|
+
//
|
|
77
|
+
// The "dir" is the single folder that holds config.ts, schema.ts, and
|
|
78
|
+
// schema.json. Resolution order:
|
|
79
|
+
// 1. --dir <path> flag (explicit)
|
|
80
|
+
// 2. Auto-detect an existing config: first d1-kyt/, then parent of
|
|
81
|
+
// wrangler migrationsDir (if it is not the project root)
|
|
82
|
+
// 3. Derive a sensible default for init: parent of wrangler migrationsDir
|
|
83
|
+
// (if it has a real parent), otherwise "d1-kyt"
|
|
84
|
+
// ----------------------------------------------------------------------------
|
|
85
|
+
|
|
86
|
+
const CONFIG_FILE = 'config.ts';
|
|
87
|
+
const SCHEMA_FILE = 'schema.ts';
|
|
88
|
+
const SNAPSHOT_FILE = 'schema.json';
|
|
89
|
+
const SCHEMA_SQL_FILE = 'schema.sql';
|
|
90
|
+
|
|
91
|
+
function toSnake(s: string): string {
|
|
92
|
+
return s.replace(/([a-z])([A-Z])/g, '$1_$2').replace(/[\s-]+/g, '_').toLowerCase();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function generateDiffName(diff: SchemaDiff): string {
|
|
96
|
+
const parts = [
|
|
97
|
+
...diff.addedTables.map((t) => `create_${toSnake(t.name)}`),
|
|
98
|
+
...diff.droppedTables.map((t) => `drop_${toSnake(t.name)}`),
|
|
99
|
+
...diff.changedTables.map((t) => `alter_${toSnake(t.name)}`),
|
|
100
|
+
];
|
|
101
|
+
if (parts.length === 0) return 'update_schema';
|
|
102
|
+
if (parts.length <= 3) return parts.join('_and_');
|
|
103
|
+
return 'update_schema';
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Return the absolute path to <dir>/config.ts, or null if no config found. */
|
|
107
|
+
function findExistingDir(dirFlag?: string): string | null {
|
|
108
|
+
if (dirFlag) {
|
|
109
|
+
const abs = resolve(process.cwd(), dirFlag);
|
|
110
|
+
return existsSync(join(abs, CONFIG_FILE)) ? abs : null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// 1. db/config.ts (default)
|
|
114
|
+
const defaultDir = resolve(process.cwd(), 'db');
|
|
115
|
+
if (existsSync(join(defaultDir, CONFIG_FILE))) return defaultDir;
|
|
116
|
+
|
|
117
|
+
// 2. Legacy d1-kyt/config.ts
|
|
118
|
+
const legacy = resolve(process.cwd(), 'd1-kyt');
|
|
119
|
+
if (existsSync(join(legacy, CONFIG_FILE))) return legacy;
|
|
120
|
+
|
|
121
|
+
// 3. Parent of wrangler migrations dir (e.g. src/ for src/migrations/)
|
|
122
|
+
const wrangler = readWranglerConfig();
|
|
123
|
+
if (wrangler) {
|
|
124
|
+
const parent = dirname(wrangler.migrationsDir);
|
|
125
|
+
if (parent !== '.') {
|
|
126
|
+
const abs = resolve(process.cwd(), parent);
|
|
127
|
+
if (existsSync(join(abs, CONFIG_FILE))) return abs;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Pick the dir to use for init (before config exists). */
|
|
135
|
+
function defaultInitDir(dirFlag?: string): string {
|
|
136
|
+
if (dirFlag) return resolve(process.cwd(), dirFlag);
|
|
137
|
+
|
|
138
|
+
const wrangler = readWranglerConfig();
|
|
139
|
+
if (wrangler) {
|
|
140
|
+
const parent = dirname(wrangler.migrationsDir);
|
|
141
|
+
if (parent !== '.') return resolve(process.cwd(), parent);
|
|
142
|
+
}
|
|
143
|
+
return resolve(process.cwd(), 'db');
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async function readD1KytConfig(dir: string): Promise<D1KytConfig | null> {
|
|
147
|
+
const configPath = join(dir, CONFIG_FILE);
|
|
148
|
+
if (!existsSync(configPath)) return null;
|
|
149
|
+
try {
|
|
150
|
+
const mod = await import(configPath);
|
|
151
|
+
return mod.default ?? mod.config;
|
|
152
|
+
} catch (err) {
|
|
153
|
+
console.error(`Error importing config:`, err);
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// ----------------------------------------------------------------------------
|
|
159
|
+
// Commands
|
|
160
|
+
// ----------------------------------------------------------------------------
|
|
161
|
+
|
|
162
|
+
function cmdInit(dirFlag?: string): void {
|
|
163
|
+
const dir = defaultInitDir(dirFlag);
|
|
164
|
+
const relDir = dir.replace(process.cwd() + '/', '');
|
|
165
|
+
|
|
166
|
+
const wrangler = readWranglerConfig();
|
|
167
|
+
const migrationsDir = wrangler?.migrationsDir ?? 'db/migrations';
|
|
168
|
+
|
|
169
|
+
if (wrangler) {
|
|
170
|
+
console.log(`Detected wrangler migrations_dir: ${migrationsDir}`);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (!existsSync(dir)) {
|
|
174
|
+
mkdirSync(dir, { recursive: true });
|
|
175
|
+
console.log(`Created: ${relDir}/`);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// config.ts
|
|
179
|
+
const configPath = join(dir, CONFIG_FILE);
|
|
180
|
+
if (!existsSync(configPath)) {
|
|
181
|
+
writeFileSync(
|
|
182
|
+
configPath,
|
|
183
|
+
`import { defineConfig } from 'd1-kyt/config';\n\nexport default defineConfig({\n migrationsDir: '${migrationsDir}',\n namingStrategy: 'sequential',\n});\n`,
|
|
184
|
+
);
|
|
185
|
+
console.log(`Created: ${relDir}/${CONFIG_FILE}`);
|
|
186
|
+
} else {
|
|
187
|
+
console.log(`Skipped: ${relDir}/${CONFIG_FILE} (already exists)`);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// schema.ts
|
|
191
|
+
const schemaPath = join(dir, SCHEMA_FILE);
|
|
192
|
+
if (!existsSync(schemaPath)) {
|
|
193
|
+
writeFileSync(
|
|
194
|
+
schemaPath,
|
|
195
|
+
`import { defineTable, defineIndex } from 'd1-kyt/schema';\nimport { createQueryBuilder } from 'd1-kyt';\nimport * as v from 'valibot';\n\n// Define your tables here, then run: d1-kyt schema:diff <name>\n//\n// export const users = defineTable('users', {\n// email: v.string(), // TEXT NOT NULL\n// name: v.optional(v.string()), // TEXT (nullable)\n// age: v.optional(v.pipe(v.number(), v.integer())), // INTEGER (nullable)\n// prefs: v.optional(v.object({ theme: v.string() })), // TEXT JSON (nullable)\n// });\n//\n// export const usersEmailIdx = defineIndex(users, ['email'], { unique: true });\n\n// Add each table to DB, then use \`db\` for type-safe query building.\nexport type DB = {\n // users: typeof users.$inferSelect;\n};\n\nexport const db = createQueryBuilder<DB>();\n`,
|
|
196
|
+
);
|
|
197
|
+
console.log(`Created: ${relDir}/${SCHEMA_FILE}`);
|
|
198
|
+
} else {
|
|
199
|
+
console.log(`Skipped: ${relDir}/${SCHEMA_FILE} (already exists)`);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// schema.json
|
|
203
|
+
const snapshotPath = join(dir, SNAPSHOT_FILE);
|
|
204
|
+
if (!existsSync(snapshotPath)) {
|
|
205
|
+
const empty: SchemaSnapshot = { version: 1, tables: {} };
|
|
206
|
+
writeFileSync(snapshotPath, JSON.stringify(empty, null, 2) + '\n');
|
|
207
|
+
console.log(`Created: ${relDir}/${SNAPSHOT_FILE}`);
|
|
208
|
+
} else {
|
|
209
|
+
console.log(`Skipped: ${relDir}/${SNAPSHOT_FILE} (already exists)`);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
console.log(`\nNext steps:`);
|
|
213
|
+
console.log(` 1. Edit: ${relDir}/${SCHEMA_FILE}`);
|
|
214
|
+
console.log(` 2. Diff: d1-kyt schema:diff <name>`);
|
|
215
|
+
console.log(` 3. Apply: wrangler d1 migrations apply <db> --local`);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
async function cmdSchemaDiff(
|
|
219
|
+
name: string | undefined,
|
|
220
|
+
dirFlag?: string,
|
|
221
|
+
schemaFlag?: string,
|
|
222
|
+
): Promise<void> {
|
|
223
|
+
const dir = findExistingDir(dirFlag);
|
|
224
|
+
if (!dir) {
|
|
225
|
+
console.error('Error: d1-kyt not initialized. Run "d1-kyt init" first.');
|
|
226
|
+
if (dirFlag) console.error(` (looked in: ${dirFlag})`);
|
|
227
|
+
process.exit(1);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const config = await readD1KytConfig(dir);
|
|
231
|
+
if (!config) {
|
|
232
|
+
console.error(`Error: Could not load config from ${join(dir, CONFIG_FILE)}`);
|
|
233
|
+
process.exit(1);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Resolve schema file path
|
|
237
|
+
const schemaPath = schemaFlag
|
|
238
|
+
? resolve(process.cwd(), schemaFlag)
|
|
239
|
+
: join(dir, SCHEMA_FILE);
|
|
240
|
+
|
|
241
|
+
if (!existsSync(schemaPath)) {
|
|
242
|
+
console.error(`Error: Schema file not found: ${schemaPath}`);
|
|
243
|
+
process.exit(1);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Load schema module
|
|
247
|
+
let schemaExports: Record<string, unknown>;
|
|
248
|
+
try {
|
|
249
|
+
schemaExports = await import(schemaPath);
|
|
250
|
+
} catch (err) {
|
|
251
|
+
console.error(`Error loading schema from ${schemaPath}:`, err);
|
|
252
|
+
process.exit(1);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Serialize → diff → SQL
|
|
256
|
+
const currentSnapshot = serializeSchema(schemaExports);
|
|
257
|
+
|
|
258
|
+
const snapshotPath = join(dir, SNAPSHOT_FILE);
|
|
259
|
+
let prevSnapshot: SchemaSnapshot = { version: 1, tables: {} };
|
|
260
|
+
const legacyPath = join(dir, 'schema.snapshot.jsonc');
|
|
261
|
+
if (existsSync(snapshotPath)) {
|
|
262
|
+
try {
|
|
263
|
+
prevSnapshot = JSON.parse(readFileSync(snapshotPath, 'utf-8')) as SchemaSnapshot;
|
|
264
|
+
} catch {
|
|
265
|
+
console.warn(`Warning: Could not parse ${SNAPSHOT_FILE}; treating as empty.`);
|
|
266
|
+
}
|
|
267
|
+
} else if (existsSync(legacyPath)) {
|
|
268
|
+
try {
|
|
269
|
+
const raw = readFileSync(legacyPath, 'utf-8')
|
|
270
|
+
.replace(/\/\/.*$/gm, '')
|
|
271
|
+
.replace(/\/\*[\s\S]*?\*\//g, '');
|
|
272
|
+
prevSnapshot = JSON.parse(raw) as SchemaSnapshot;
|
|
273
|
+
} catch {
|
|
274
|
+
console.warn(`Warning: Could not parse legacy snapshot; treating as empty.`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const diff = diffSnapshots(prevSnapshot, currentSnapshot);
|
|
279
|
+
const statements = diffToSQL(diff);
|
|
280
|
+
|
|
281
|
+
if (statements.length === 0) {
|
|
282
|
+
console.log('Schema is up to date.');
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// Write migration file
|
|
287
|
+
const outDir = resolve(process.cwd(), config.migrationsDir);
|
|
288
|
+
if (!existsSync(outDir)) mkdirSync(outDir, { recursive: true });
|
|
289
|
+
|
|
290
|
+
const existingFiles = readdirSync(outDir);
|
|
291
|
+
const strategy = config.namingStrategy ?? 'sequential';
|
|
292
|
+
const prefix = generateMigrationPrefix(strategy, existingFiles);
|
|
293
|
+
|
|
294
|
+
const snakeName = name ? toSnake(name) : generateDiffName(diff);
|
|
295
|
+
|
|
296
|
+
const filename = `${prefix}_${snakeName}.sql`;
|
|
297
|
+
const sql =
|
|
298
|
+
`-- Generated by d1-kyt schema:diff\n` +
|
|
299
|
+
`-- ${new Date().toISOString()}\n\n` +
|
|
300
|
+
`${statements.join('\n\n')}\n`;
|
|
301
|
+
|
|
302
|
+
writeFileSync(join(outDir, filename), sql);
|
|
303
|
+
console.log(`Created: ${config.migrationsDir}/${filename}`);
|
|
304
|
+
|
|
305
|
+
// Update snapshot
|
|
306
|
+
writeFileSync(snapshotPath, JSON.stringify(currentSnapshot, null, 2) + '\n');
|
|
307
|
+
const relDir = dir.replace(process.cwd() + '/', '');
|
|
308
|
+
console.log(`Updated: ${relDir}/${SNAPSHOT_FILE}`);
|
|
309
|
+
|
|
310
|
+
// Write schema.sql (full DDL from empty → current)
|
|
311
|
+
const fullStatements = diffToSQL(diffSnapshots({ version: 1, tables: {} }, currentSnapshot));
|
|
312
|
+
const schemaSql =
|
|
313
|
+
`-- Generated by d1-kyt schema:diff\n` +
|
|
314
|
+
`-- Full schema as of: ${new Date().toISOString()}\n\n` +
|
|
315
|
+
`${fullStatements.join('\n\n')}\n`;
|
|
316
|
+
writeFileSync(join(dir, SCHEMA_SQL_FILE), schemaSql);
|
|
317
|
+
console.log(`Updated: ${relDir}/${SCHEMA_SQL_FILE}`);
|
|
318
|
+
|
|
319
|
+
console.log(`\nRun: wrangler d1 migrations apply <db> --local`);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// ----------------------------------------------------------------------------
|
|
323
|
+
// Arg helpers
|
|
324
|
+
// ----------------------------------------------------------------------------
|
|
325
|
+
|
|
326
|
+
function flagValue(args: string[], flag: string): string | undefined {
|
|
327
|
+
const idx = args.indexOf(flag);
|
|
328
|
+
return idx !== -1 ? args[idx + 1] : undefined;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// ----------------------------------------------------------------------------
|
|
332
|
+
// Main
|
|
333
|
+
// ----------------------------------------------------------------------------
|
|
334
|
+
|
|
335
|
+
async function main(): Promise<void> {
|
|
336
|
+
const args = process.argv.slice(2);
|
|
337
|
+
const command = args[0];
|
|
338
|
+
|
|
339
|
+
if (!command || command === '--help' || command === '-h') {
|
|
340
|
+
console.log(HELP);
|
|
341
|
+
process.exit(0);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
if (command === '--version' || command === '-v') {
|
|
345
|
+
console.log(VERSION);
|
|
346
|
+
process.exit(0);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
switch (command) {
|
|
350
|
+
case 'init':
|
|
351
|
+
cmdInit(flagValue(args, '--dir'));
|
|
352
|
+
break;
|
|
353
|
+
|
|
354
|
+
case 'schema:diff': {
|
|
355
|
+
const maybeName = args[1];
|
|
356
|
+
const name = maybeName && !maybeName.startsWith('--') ? maybeName : undefined;
|
|
357
|
+
await cmdSchemaDiff(name, flagValue(args, '--dir'), flagValue(args, '--schema'));
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
default:
|
|
362
|
+
console.error(`Unknown command: ${command}`);
|
|
363
|
+
console.log(HELP);
|
|
364
|
+
process.exit(1);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
main();
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// ----------------------------------------------------------------------------
|
|
2
|
+
// Config Types
|
|
3
|
+
// ----------------------------------------------------------------------------
|
|
4
|
+
|
|
5
|
+
export type NamingStrategy = 'sequential' | 'timestamp';
|
|
6
|
+
|
|
7
|
+
export interface D1KytConfig {
|
|
8
|
+
migrationsDir: string;
|
|
9
|
+
namingStrategy: NamingStrategy;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// ----------------------------------------------------------------------------
|
|
13
|
+
// defineConfig
|
|
14
|
+
// ----------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
export function defineConfig(config: D1KytConfig): D1KytConfig {
|
|
17
|
+
return config;
|
|
18
|
+
}
|