@deessejs/cli 0.3.0 → 0.3.2
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/commands/db-generate.d.ts +5 -8
- package/dist/commands/db-generate.d.ts.map +1 -1
- package/dist/commands/db-generate.js +25 -52
- package/dist/commands/db-generate.js.map +1 -1
- package/dist/commands/db-introspect.d.ts +4 -6
- package/dist/commands/db-introspect.d.ts.map +1 -1
- package/dist/commands/db-introspect.js +17 -65
- package/dist/commands/db-introspect.js.map +1 -1
- package/dist/commands/db-migrate.d.ts +4 -6
- package/dist/commands/db-migrate.d.ts.map +1 -1
- package/dist/commands/db-migrate.js +22 -66
- package/dist/commands/db-migrate.js.map +1 -1
- package/dist/commands/db-push.d.ts +4 -8
- package/dist/commands/db-push.d.ts.map +1 -1
- package/dist/commands/db-push.js +18 -54
- package/dist/commands/db-push.js.map +1 -1
- package/dist/commands/db-studio.d.ts +3 -4
- package/dist/commands/db-studio.d.ts.map +1 -1
- package/dist/commands/db-studio.js +16 -39
- package/dist/commands/db-studio.js.map +1 -1
- package/package.json +2 -3
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* db:generate command
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Verifies schema setup and provides instructions for generating migrations.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* 3. Get previous snapshot from ./src/db/meta/_snapshot.json (if exists)
|
|
10
|
-
* 4. Generate migration SQL using generateMigration
|
|
11
|
-
* 5. Save new snapshot and migration files
|
|
6
|
+
* For Drizzle, run these commands:
|
|
7
|
+
* npx drizzle-kit generate
|
|
8
|
+
* npx drizzle-kit push
|
|
12
9
|
*/
|
|
13
10
|
export interface DbGenerateOptions {
|
|
14
11
|
cwd?: string;
|
|
15
12
|
}
|
|
16
|
-
export declare function dbGenerate(
|
|
13
|
+
export declare function dbGenerate(_options?: DbGenerateOptions): Promise<void>;
|
|
17
14
|
//# sourceMappingURL=db-generate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-generate.d.ts","sourceRoot":"","sources":["../../src/commands/db-generate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"db-generate.d.ts","sourceRoot":"","sources":["../../src/commands/db-generate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,MAAM,WAAW,iBAAiB;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,wBAAsB,UAAU,CAAC,QAAQ,GAAE,iBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8BhF"}
|
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* db:generate command
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Verifies schema setup and provides instructions for generating migrations.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* 3. Get previous snapshot from ./src/db/meta/_snapshot.json (if exists)
|
|
10
|
-
* 4. Generate migration SQL using generateMigration
|
|
11
|
-
* 5. Save new snapshot and migration files
|
|
6
|
+
* For Drizzle, run these commands:
|
|
7
|
+
* npx drizzle-kit generate
|
|
8
|
+
* npx drizzle-kit push
|
|
12
9
|
*/
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
import { generateDrizzleJson, generateMigration, } from 'drizzle-kit/api';
|
|
16
|
-
import { loadSchema, verifySchemaPath } from '../utils/schema-loader.js';
|
|
17
|
-
const SCHEMA_PATH = './src/db/schema.ts';
|
|
18
|
-
const MIGRATIONS_DIR = './src/db/migrations';
|
|
19
|
-
const SNAPSHOT_DIR = './src/db/meta';
|
|
20
|
-
const SNAPSHOT_FILE = '_snapshot.json';
|
|
21
|
-
export async function dbGenerate(options = {}) {
|
|
22
|
-
const cwd = options.cwd ?? process.cwd();
|
|
10
|
+
import { verifySchemaPath, SCHEMA_PATH } from '../utils/schema-loader.js';
|
|
11
|
+
export async function dbGenerate(_options = {}) {
|
|
23
12
|
// Verify schema file exists
|
|
24
13
|
try {
|
|
25
14
|
await verifySchemaPath();
|
|
@@ -28,40 +17,24 @@ export async function dbGenerate(options = {}) {
|
|
|
28
17
|
throw new Error(`db:generate requires ${SCHEMA_PATH} to exist.\n` +
|
|
29
18
|
`Please create this file and export your Drizzle tables.`);
|
|
30
19
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// Generate migration SQL
|
|
51
|
-
const migrationSql = await generateMigration(prevSchema ?? undefined, currentSchema);
|
|
52
|
-
if (!migrationSql || migrationSql.length === 0) {
|
|
53
|
-
console.warn('No changes detected. No migration to generate.');
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
// Generate migration file name based on timestamp
|
|
57
|
-
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
|
|
58
|
-
const migrationName = `${timestamp}_migration.sql`;
|
|
59
|
-
const migrationPath = path.join(cwd, MIGRATIONS_DIR, migrationName);
|
|
60
|
-
// Save migration file
|
|
61
|
-
await fs.writeFile(migrationPath, migrationSql.join('\n\n'));
|
|
62
|
-
// Save new snapshot
|
|
63
|
-
await fs.writeFile(snapshotPath, JSON.stringify(currentSchema, null, 2));
|
|
64
|
-
console.warn(`Generated migration: ${migrationName}`);
|
|
65
|
-
console.warn(`Migration saved to: ${MIGRATIONS_DIR}/${migrationName}`);
|
|
20
|
+
console.warn(`
|
|
21
|
+
Database Schema OK: ${SCHEMA_PATH}
|
|
22
|
+
|
|
23
|
+
To generate migrations with Drizzle, run these commands:
|
|
24
|
+
|
|
25
|
+
npx drizzle-kit generate
|
|
26
|
+
npx drizzle-kit push
|
|
27
|
+
|
|
28
|
+
Note: These commands require a drizzle.config.ts file. If you don't have one,
|
|
29
|
+
create it with:
|
|
30
|
+
|
|
31
|
+
import { defineConfig } from 'drizzle-kit';
|
|
32
|
+
|
|
33
|
+
export default defineConfig({
|
|
34
|
+
schema: './src/db/schema.ts',
|
|
35
|
+
out: './src/db/migrations',
|
|
36
|
+
dialect: 'postgresql',
|
|
37
|
+
});
|
|
38
|
+
`);
|
|
66
39
|
}
|
|
67
40
|
//# sourceMappingURL=db-generate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-generate.js","sourceRoot":"","sources":["../../src/commands/db-generate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"db-generate.js","sourceRoot":"","sources":["../../src/commands/db-generate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAM1E,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,WAA8B,EAAE;IAC/D,4BAA4B;IAC5B,IAAI,CAAC;QACH,MAAM,gBAAgB,EAAE,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,wBAAwB,WAAW,cAAc;YACjD,yDAAyD,CAC1D,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,IAAI,CAAC;sBACO,WAAW;;;;;;;;;;;;;;;;;CAiBhC,CAAC,CAAC;AACH,CAAC"}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* db:introspect command
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Verifies schema setup and provides instructions for introspecting database.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* 2. Spawn drizzle-kit introspect command
|
|
9
|
-
* 3. Note: Introspection result needs to be processed manually
|
|
6
|
+
* For Drizzle, run:
|
|
7
|
+
* npx drizzle-kit introspect
|
|
10
8
|
*/
|
|
11
9
|
export interface DbIntrospectOptions {
|
|
12
10
|
cwd?: string;
|
|
13
11
|
force?: boolean;
|
|
14
12
|
}
|
|
15
|
-
export declare function dbIntrospect(
|
|
13
|
+
export declare function dbIntrospect(_options?: DbIntrospectOptions): Promise<void>;
|
|
16
14
|
//# sourceMappingURL=db-introspect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-introspect.d.ts","sourceRoot":"","sources":["../../src/commands/db-introspect.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"db-introspect.d.ts","sourceRoot":"","sources":["../../src/commands/db-introspect.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,MAAM,WAAW,mBAAmB;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,wBAAsB,YAAY,CAAC,QAAQ,GAAE,mBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBpF"}
|
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* db:introspect command
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Verifies schema setup and provides instructions for introspecting database.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* 2. Spawn drizzle-kit introspect command
|
|
9
|
-
* 3. Note: Introspection result needs to be processed manually
|
|
6
|
+
* For Drizzle, run:
|
|
7
|
+
* npx drizzle-kit introspect
|
|
10
8
|
*/
|
|
11
|
-
import { execSync } from 'node:child_process';
|
|
12
9
|
import { loadConfig } from '../utils/config.js';
|
|
13
10
|
import { detectDialect } from '../utils/dialect.js';
|
|
14
|
-
|
|
15
|
-
import * as fs from 'node:fs/promises';
|
|
16
|
-
import * as path from 'node:path';
|
|
17
|
-
import * as p from '@clack/prompts';
|
|
18
|
-
export async function dbIntrospect(options = {}) {
|
|
19
|
-
const { cwd = process.cwd(), force = false } = options;
|
|
11
|
+
export async function dbIntrospect(_options = {}) {
|
|
20
12
|
// Load config to verify database is configured
|
|
21
13
|
const { config } = await loadConfig();
|
|
22
14
|
const db = config.database;
|
|
@@ -25,58 +17,18 @@ export async function dbIntrospect(options = {}) {
|
|
|
25
17
|
}
|
|
26
18
|
// Detect dialect
|
|
27
19
|
const dialect = detectDialect(db);
|
|
28
|
-
console.warn(`
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
await fs.access(schemaPath);
|
|
42
|
-
if (!force) {
|
|
43
|
-
const confirm = await p.confirm({
|
|
44
|
-
message: `Warning: ${SCHEMA_PATH} already exists. Overwrite?`,
|
|
45
|
-
initialValue: false,
|
|
46
|
-
});
|
|
47
|
-
if (p.isCancel(confirm) || !confirm) {
|
|
48
|
-
p.cancel('Introspect cancelled.');
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
catch {
|
|
54
|
-
// File doesn't exist, that's fine
|
|
55
|
-
}
|
|
56
|
-
try {
|
|
57
|
-
// Try to run drizzle-kit introspect
|
|
58
|
-
// Note: This requires drizzle.config.ts to be configured properly
|
|
59
|
-
execSync(`npx ${args.join(' ')}`, {
|
|
60
|
-
cwd,
|
|
61
|
-
stdio: 'inherit',
|
|
62
|
-
});
|
|
63
|
-
console.warn('');
|
|
64
|
-
console.warn('Introspection complete!');
|
|
65
|
-
console.warn('');
|
|
66
|
-
console.warn('Note: drizzle-kit generates a drizzle schema file, not src/db/schema.ts.');
|
|
67
|
-
console.warn('You may need to manually copy the generated schema to src/db/schema.ts');
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
if (error.code === 'ENOENT') {
|
|
71
|
-
throw new Error('drizzle-kit not found. Please install it: npm install drizzle-kit');
|
|
72
|
-
}
|
|
73
|
-
console.warn('');
|
|
74
|
-
console.warn('Drizzle Kit introspection requires a drizzle.config.ts file.');
|
|
75
|
-
console.warn('For full introspection support, please:');
|
|
76
|
-
console.warn('1. Create a drizzle.config.ts file');
|
|
77
|
-
console.warn('2. Run: npx drizzle-kit introspect');
|
|
78
|
-
console.warn('');
|
|
79
|
-
throw error;
|
|
80
|
-
}
|
|
20
|
+
console.warn(`
|
|
21
|
+
Database Config OK
|
|
22
|
+
|
|
23
|
+
Detected dialect: ${dialect}
|
|
24
|
+
|
|
25
|
+
To introspect your database and generate a schema file, run:
|
|
26
|
+
|
|
27
|
+
npx drizzle-kit introspect
|
|
28
|
+
|
|
29
|
+
This will generate/update a schema file based on your database tables.
|
|
30
|
+
|
|
31
|
+
Note: This command requires a drizzle.config.ts file. See 'deesse db:generate' for setup.
|
|
32
|
+
`);
|
|
81
33
|
}
|
|
82
34
|
//# sourceMappingURL=db-introspect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-introspect.js","sourceRoot":"","sources":["../../src/commands/db-introspect.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"db-introspect.js","sourceRoot":"","sources":["../../src/commands/db-introspect.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAOpD,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,WAAgC,EAAE;IACnE,+CAA+C;IAC/C,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,UAAU,EAAE,CAAC;IACtC,MAAM,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC;IAE3B,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IAED,iBAAiB;IACjB,MAAM,OAAO,GAAG,aAAa,CAAC,EAAE,CAAC,CAAC;IAElC,OAAO,CAAC,IAAI,CAAC;;;oBAGK,OAAO;;;;;;;;;CAS1B,CAAC,CAAC;AACH,CAAC"}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* db:migrate command
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Verifies schema setup and provides instructions for applying migrations.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* 2. Get migration files from ./src/db/migrations
|
|
9
|
-
* 3. Execute each migration in order
|
|
6
|
+
* For Drizzle, run:
|
|
7
|
+
* npx drizzle-kit migrate
|
|
10
8
|
*/
|
|
11
9
|
export interface DbMigrateOptions {
|
|
12
10
|
cwd?: string;
|
|
13
11
|
dryRun?: boolean;
|
|
14
12
|
}
|
|
15
|
-
export declare function dbMigrate(
|
|
13
|
+
export declare function dbMigrate(_options?: DbMigrateOptions): Promise<void>;
|
|
16
14
|
//# sourceMappingURL=db-migrate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-migrate.d.ts","sourceRoot":"","sources":["../../src/commands/db-migrate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"db-migrate.d.ts","sourceRoot":"","sources":["../../src/commands/db-migrate.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAsB,SAAS,CAAC,QAAQ,GAAE,gBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwB9E"}
|
|
@@ -1,77 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* db:migrate command
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Verifies schema setup and provides instructions for applying migrations.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* 2. Get migration files from ./src/db/migrations
|
|
9
|
-
* 3. Execute each migration in order
|
|
6
|
+
* For Drizzle, run:
|
|
7
|
+
* npx drizzle-kit migrate
|
|
10
8
|
*/
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const MIGRATIONS_DIR = './src/db/migrations';
|
|
15
|
-
async function getMigrationFiles(cwd) {
|
|
16
|
-
const migrationsPath = path.join(cwd, MIGRATIONS_DIR);
|
|
9
|
+
import { verifySchemaPath, SCHEMA_PATH } from '../utils/schema-loader.js';
|
|
10
|
+
export async function dbMigrate(_options = {}) {
|
|
11
|
+
// Verify schema file exists
|
|
17
12
|
try {
|
|
18
|
-
|
|
19
|
-
return files
|
|
20
|
-
.filter((file) => file.endsWith('.sql'))
|
|
21
|
-
.map((name) => ({
|
|
22
|
-
name,
|
|
23
|
-
path: path.join(migrationsPath, name),
|
|
24
|
-
}))
|
|
25
|
-
.sort((a, b) => a.name.localeCompare(b.name));
|
|
13
|
+
await verifySchemaPath();
|
|
26
14
|
}
|
|
27
15
|
catch {
|
|
28
|
-
|
|
16
|
+
throw new Error(`db:migrate requires ${SCHEMA_PATH} to exist.\n` +
|
|
17
|
+
`Please create this file and export your Drizzle tables.`);
|
|
29
18
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
console.warn(`Found ${files.length} migration(s) to apply.\n`);
|
|
46
|
-
if (dryRun) {
|
|
47
|
-
console.warn('Dry run - showing migrations that would be applied:');
|
|
48
|
-
for (const file of files) {
|
|
49
|
-
console.warn(` - ${file.name}`);
|
|
50
|
-
}
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
// Apply each migration
|
|
54
|
-
for (const file of files) {
|
|
55
|
-
const sql = await fs.readFile(file.path, 'utf-8');
|
|
56
|
-
console.warn(`Applying: ${file.name}`);
|
|
57
|
-
try {
|
|
58
|
-
// Execute the migration
|
|
59
|
-
// Note: The actual execution depends on the database driver
|
|
60
|
-
// For pg, we use db.execute() which returns a query result
|
|
61
|
-
if (typeof db.execute === 'function') {
|
|
62
|
-
await db.execute(sql);
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
throw new Error('Database driver does not support execute(). ' +
|
|
66
|
-
'Please use a supported driver like drizzle-orm/node-postgres.');
|
|
67
|
-
}
|
|
68
|
-
console.warn(` Applied successfully`);
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
console.error(` Failed: ${error.message}`);
|
|
72
|
-
throw error;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
console.warn(`\nSuccessfully applied ${files.length} migration(s).`);
|
|
19
|
+
console.warn(`
|
|
20
|
+
Database Schema OK: ${SCHEMA_PATH}
|
|
21
|
+
|
|
22
|
+
To apply pending migrations with Drizzle, run:
|
|
23
|
+
|
|
24
|
+
npx drizzle-kit migrate
|
|
25
|
+
|
|
26
|
+
Use --dry-run to see what would be applied:
|
|
27
|
+
|
|
28
|
+
npx drizzle-kit migrate --dry
|
|
29
|
+
|
|
30
|
+
Note: This command requires a drizzle.config.ts file. See 'deesse db:generate' for setup.
|
|
31
|
+
`);
|
|
76
32
|
}
|
|
77
33
|
//# sourceMappingURL=db-migrate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-migrate.js","sourceRoot":"","sources":["../../src/commands/db-migrate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"db-migrate.js","sourceRoot":"","sources":["../../src/commands/db-migrate.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAO1E,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,WAA6B,EAAE;IAC7D,4BAA4B;IAC5B,IAAI,CAAC;QACH,MAAM,gBAAgB,EAAE,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,uBAAuB,WAAW,cAAc;YAChD,yDAAyD,CAC1D,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,IAAI,CAAC;sBACO,WAAW;;;;;;;;;;;CAWhC,CAAC,CAAC;AACH,CAAC"}
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* db:push command
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* Uses drizzle-kit's pushSchema programmatic API.
|
|
4
|
+
* Verifies schema setup and provides instructions for pushing schema to database.
|
|
6
5
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* 2. Load config to get database instance
|
|
10
|
-
* 3. Call pushSchema with the schema
|
|
11
|
-
* 4. Show warnings and apply if confirmed (or force)
|
|
6
|
+
* For Drizzle, run:
|
|
7
|
+
* npx drizzle-kit push
|
|
12
8
|
*/
|
|
13
9
|
export interface DbPushOptions {
|
|
14
10
|
force?: boolean;
|
|
15
11
|
cwd?: string;
|
|
16
12
|
}
|
|
17
|
-
export declare function dbPush(
|
|
13
|
+
export declare function dbPush(_options?: DbPushOptions): Promise<void>;
|
|
18
14
|
//# sourceMappingURL=db-push.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-push.d.ts","sourceRoot":"","sources":["../../src/commands/db-push.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"db-push.d.ts","sourceRoot":"","sources":["../../src/commands/db-push.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,wBAAsB,MAAM,CAAC,QAAQ,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwBxE"}
|
package/dist/commands/db-push.js
CHANGED
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* db:push command
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* Uses drizzle-kit's pushSchema programmatic API.
|
|
4
|
+
* Verifies schema setup and provides instructions for pushing schema to database.
|
|
6
5
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* 2. Load config to get database instance
|
|
10
|
-
* 3. Call pushSchema with the schema
|
|
11
|
-
* 4. Show warnings and apply if confirmed (or force)
|
|
6
|
+
* For Drizzle, run:
|
|
7
|
+
* npx drizzle-kit push
|
|
12
8
|
*/
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
import { loadSchema, verifySchemaPath, SCHEMA_PATH } from '../utils/schema-loader.js';
|
|
16
|
-
import * as p from '@clack/prompts';
|
|
17
|
-
export async function dbPush(options = {}) {
|
|
18
|
-
const { force = false } = options;
|
|
9
|
+
import { verifySchemaPath, SCHEMA_PATH } from '../utils/schema-loader.js';
|
|
10
|
+
export async function dbPush(_options = {}) {
|
|
19
11
|
// Verify schema file exists
|
|
20
12
|
try {
|
|
21
13
|
await verifySchemaPath();
|
|
@@ -24,46 +16,18 @@ export async function dbPush(options = {}) {
|
|
|
24
16
|
throw new Error(`db:push requires ${SCHEMA_PATH} to exist.\n` +
|
|
25
17
|
`Please create this file and export your Drizzle tables.`);
|
|
26
18
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
p.note('The following changes may cause data loss:', 'Warning');
|
|
41
|
-
for (const warning of result.warnings) {
|
|
42
|
-
console.warn(` - ${warning}`);
|
|
43
|
-
}
|
|
44
|
-
console.warn('');
|
|
45
|
-
const confirm = await p.confirm({
|
|
46
|
-
message: 'Do you want to apply these changes anyway?',
|
|
47
|
-
initialValue: false,
|
|
48
|
-
});
|
|
49
|
-
if (p.isCancel(confirm) || !confirm) {
|
|
50
|
-
p.cancel('Push cancelled.');
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
else if (result.warnings.length > 0) {
|
|
55
|
-
p.note(result.warnings.join('\n'), 'Warnings');
|
|
56
|
-
}
|
|
57
|
-
// Show statements that will be executed
|
|
58
|
-
if (result.statementsToExecute.length > 0) {
|
|
59
|
-
console.warn('The following SQL will be executed:');
|
|
60
|
-
for (const stmt of result.statementsToExecute) {
|
|
61
|
-
console.warn(` ${stmt}`);
|
|
62
|
-
}
|
|
63
|
-
console.warn('');
|
|
64
|
-
}
|
|
65
|
-
// Apply the changes
|
|
66
|
-
await result.apply();
|
|
67
|
-
console.warn(`Successfully pushed ${result.statementsToExecute.length} changes to the database.`);
|
|
19
|
+
console.warn(`
|
|
20
|
+
Database Schema OK: ${SCHEMA_PATH}
|
|
21
|
+
|
|
22
|
+
To push schema changes to your database with Drizzle, run:
|
|
23
|
+
|
|
24
|
+
npx drizzle-kit push
|
|
25
|
+
|
|
26
|
+
Use --force flag to skip confirmation:
|
|
27
|
+
|
|
28
|
+
npx drizzle-kit push --force
|
|
29
|
+
|
|
30
|
+
Note: This command requires a drizzle.config.ts file. See 'deesse db:generate' for setup.
|
|
31
|
+
`);
|
|
68
32
|
}
|
|
69
33
|
//# sourceMappingURL=db-push.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-push.js","sourceRoot":"","sources":["../../src/commands/db-push.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"db-push.js","sourceRoot":"","sources":["../../src/commands/db-push.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAO1E,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,WAA0B,EAAE;IACvD,4BAA4B;IAC5B,IAAI,CAAC;QACH,MAAM,gBAAgB,EAAE,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,oBAAoB,WAAW,cAAc;YAC7C,yDAAyD,CAC1D,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,IAAI,CAAC;sBACO,WAAW;;;;;;;;;;;CAWhC,CAAC,CAAC;AACH,CAAC"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* db:studio command
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Verifies schema setup and provides instructions for opening Drizzle Studio.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* 2. Spawn drizzle-kit studio command with appropriate arguments
|
|
6
|
+
* For Drizzle, run:
|
|
7
|
+
* npx drizzle-kit studio
|
|
9
8
|
*/
|
|
10
9
|
export interface DbStudioOptions {
|
|
11
10
|
port?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-studio.d.ts","sourceRoot":"","sources":["../../src/commands/db-studio.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"db-studio.d.ts","sourceRoot":"","sources":["../../src/commands/db-studio.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,wBAAsB,QAAQ,CAAC,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CA6C3E"}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* db:studio command
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Verifies schema setup and provides instructions for opening Drizzle Studio.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* 2. Spawn drizzle-kit studio command with appropriate arguments
|
|
6
|
+
* For Drizzle, run:
|
|
7
|
+
* npx drizzle-kit studio
|
|
9
8
|
*/
|
|
10
|
-
import { execSync } from 'node:child_process';
|
|
11
9
|
import { verifySchemaPath, SCHEMA_PATH } from '../utils/schema-loader.js';
|
|
12
10
|
import { detectDialect } from '../utils/dialect.js';
|
|
13
11
|
import { loadConfig } from '../utils/config.js';
|
|
14
12
|
export async function dbStudio(options = {}) {
|
|
15
|
-
const cwd = options.cwd ?? process.cwd();
|
|
16
13
|
const port = options.port ?? parseInt(process.env['DB_STUDIO_PORT'] ?? '4983', 10);
|
|
17
14
|
const host = options.host ?? process.env['DB_STUDIO_HOST'] ?? '127.0.0.1';
|
|
18
15
|
// Verify schema file exists
|
|
@@ -35,38 +32,18 @@ export async function dbStudio(options = {}) {
|
|
|
35
32
|
throw new Error(`Drizzle Studio currently only supports PostgreSQL.\n` +
|
|
36
33
|
`Detected dialect: ${dialect}`);
|
|
37
34
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
console.warn(`Since we don't use drizzle.config.ts, please either:`);
|
|
52
|
-
console.warn(`1. Create a minimal drizzle.config.ts pointing to your schema`);
|
|
53
|
-
console.warn(`2. Or use 'npx drizzle-kit studio' directly with a config file`);
|
|
54
|
-
console.warn('');
|
|
55
|
-
// Try to spawn drizzle-kit anyway - it might work if user has a config
|
|
56
|
-
try {
|
|
57
|
-
execSync(`npx ${args.join(' ')}`, {
|
|
58
|
-
cwd,
|
|
59
|
-
stdio: 'inherit',
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
catch (error) {
|
|
63
|
-
if (error.code === 'ENOENT') {
|
|
64
|
-
throw new Error('drizzle-kit not found. Please install it: npm install drizzle-kit');
|
|
65
|
-
}
|
|
66
|
-
// Drizzle-kit studio might fail if no config - show helpful message
|
|
67
|
-
console.warn('Drizzle Studio requires a drizzle.config.ts file to work.');
|
|
68
|
-
console.warn('For now, please use: npx drizzle-kit studio');
|
|
69
|
-
throw error;
|
|
70
|
-
}
|
|
35
|
+
console.warn(`
|
|
36
|
+
Database Schema OK: ${SCHEMA_PATH}
|
|
37
|
+
|
|
38
|
+
To open Drizzle Studio, run:
|
|
39
|
+
|
|
40
|
+
npx drizzle-kit studio
|
|
41
|
+
|
|
42
|
+
Or with custom host/port:
|
|
43
|
+
|
|
44
|
+
npx drizzle-kit studio --host ${host} --port ${port}
|
|
45
|
+
|
|
46
|
+
Note: This command requires a drizzle.config.ts file. See 'deesse db:generate' for setup.
|
|
47
|
+
`);
|
|
71
48
|
}
|
|
72
49
|
//# sourceMappingURL=db-studio.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-studio.js","sourceRoot":"","sources":["../../src/commands/db-studio.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"db-studio.js","sourceRoot":"","sources":["../../src/commands/db-studio.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAQhD,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,UAA2B,EAAE;IAC1D,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,MAAM,EAAE,EAAE,CAAC,CAAC;IACnF,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,WAAW,CAAC;IAE1E,4BAA4B;IAC5B,IAAI,CAAC;QACH,MAAM,gBAAgB,EAAE,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,sBAAsB,WAAW,cAAc;YAC/C,yDAAyD,CAC1D,CAAC;IACJ,CAAC;IAED,+CAA+C;IAC/C,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,UAAU,EAAE,CAAC;IACtC,MAAM,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC;IAE3B,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IAED,iBAAiB;IACjB,MAAM,OAAO,GAAG,aAAa,CAAC,EAAE,CAAC,CAAC;IAElC,IAAI,OAAO,KAAK,YAAY,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CACb,sDAAsD;YACtD,qBAAqB,OAAO,EAAE,CAC/B,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,IAAI,CAAC;sBACO,WAAW;;;;;;;;kCAQC,IAAI,WAAW,IAAI;;;CAGpD,CAAC,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deessejs/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "DeesseJS CLI for managing DeesseJS projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -24,8 +24,7 @@
|
|
|
24
24
|
"author": "DeesseJS",
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@clack/prompts": "^0.8.2"
|
|
28
|
-
"drizzle-kit": "^0.30.0"
|
|
27
|
+
"@clack/prompts": "^0.8.2"
|
|
29
28
|
},
|
|
30
29
|
"devDependencies": {
|
|
31
30
|
"@types/node": "^22.10.6",
|