Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
5830618
feat: initial db pull implementation
svetch Sep 23, 2025
df3ac3c
fix: generate imports and attributes for zmodel-code-generator
svetch Sep 24, 2025
a22b07a
fix: add option to not exclude imports in loadDocument
svetch Sep 24, 2025
6cc49fe
fix: continue work on db pull
svetch Sep 24, 2025
1766e6e
fix: missing import
svetch Sep 24, 2025
649cc86
fix: rewrite model generation
svetch Sep 26, 2025
0f9b24f
feat: add ast factory
svetch Oct 5, 2025
bd0fc90
fix: ast factory import order
svetch Oct 5, 2025
fcea748
fix: some runtime bugs
svetch Oct 6, 2025
c518fec
fix: lint fix
svetch Oct 20, 2025
e18ae1d
fix: update zmodel code generator
svetch Oct 20, 2025
63f5015
feat: add exclude schemas option
svetch Oct 20, 2025
29a3f0b
feat: implement initial diff update
svetch Oct 20, 2025
1a6f840
fix: update format in zmodel code generator
svetch Oct 20, 2025
a052553
fix: typo
svetch Oct 20, 2025
debb9ac
feat: progress on database introspection and syncing
svetch Oct 21, 2025
716dee5
fix: make ignore behave it does in prisma with no index models
svetch Oct 21, 2025
420fe25
fix: lint fix
svetch Oct 21, 2025
26e14c0
feat: make all format options configurable
svetch Oct 21, 2025
afa2142
fix: lint fix
svetch Oct 21, 2025
3b40b40
feat: Handle the database type mapping
svetch Oct 22, 2025
c2b84dd
fix: catch up with feature updates
svetch Nov 12, 2025
d18102e
fix: add sqlite e2e test and fix some bugs
svetch Nov 21, 2025
099d576
fix: lint fix
svetch Nov 21, 2025
3fb6ccc
fix: formatting for e2e test schemas
svetch Nov 21, 2025
7283cc7
test: run db pull e2e test also for postgres
svetch Nov 21, 2025
0625bcc
fix: postgres instorspection schema filter
svetch Nov 23, 2025
164b193
test: update cli tests
svetch Nov 23, 2025
371a122
feat(cli): Improves database introspection and syncing
svetch Dec 15, 2025
575f0c8
fix(cli): fixes field casing and sort issues
svetch Jan 9, 2026
219337d
chore(cli): remove temporary test script
svetch Jan 27, 2026
098873e
chore: update pnpm-lock.yaml
svetch Jan 27, 2026
99f180e
feat(cli): add MySQL support for schema introspection
svetch Jan 27, 2026
4da745d
fix(cli): improve field matching logic during db pull
svetch Jan 27, 2026
aed3efe
feat(cli): enhance SQLite introspection with autoincrement support
svetch Jan 27, 2026
2cf701e
fix(cli): refine attribute generation in db pull
svetch Jan 27, 2026
ba1aff1
test(cli): update db pull tests for SQLite specific behavior
svetch Jan 27, 2026
96c5dc6
refactor(language): export ZModelServices type
svetch Jan 27, 2026
c9f8013
fix(cli): improve sqlite introspection for autoincrement and fk names
svetch Jan 28, 2026
5884eff
feat(cli): enhance field matching logic during pull by using relation…
svetch Jan 28, 2026
2c9ccb7
refactor(cli): refine relation name generation and table syncing
svetch Jan 28, 2026
89a15b5
test(cli): update pull tests to reflect improved schema generation
svetch Jan 28, 2026
f433883
test(cli): add MySQL support to test utility helpers
svetch Jan 28, 2026
5c08cbd
fix(cli): omit default constraint names in table sync
svetch Jan 28, 2026
1df6926
fix: correctly handle default values for 'text' type in PostgreSQL
svetch Jan 28, 2026
d5b8397
fix: sort table indexes to ensure stable schema generation
svetch Jan 28, 2026
05ad8e2
refactor: dynamically determine supported db providers in CLI
svetch Jan 28, 2026
d0e1242
test: fix typo in pull test description
svetch Jan 28, 2026
c3ae802
chore(cli): remove debug artifacts and silence test logs
svetch Jan 28, 2026
caee3f7
fix(cli): ensure MySQL column and index ordering
svetch Jan 29, 2026
5c3265a
fix(cli): preserve column order during MySQL pull
svetch Jan 30, 2026
f6eda1d
refactor(cli): remove schema fields from MySQL queries
svetch Jan 30, 2026
1086be6
fix(cli): improve MySQL introspection and index mapping
svetch Jan 30, 2026
dbd8d7a
test(cli): pass provider to default prelude in tests
svetch Jan 30, 2026
50b0dd2
fix(cli): improve MySQL introspection for types and defaults
svetch Jan 30, 2026
2dcc361
fix(cli): improve MySQL default value introspection
svetch Jan 30, 2026
347ed34
test(cli): expand and reorganize db pull tests
svetch Jan 30, 2026
5887798
refactor: restructure introspection provider interface and attribute …
svetch Jan 30, 2026
95051e5
feat: modernize MySQL introspection provider
svetch Jan 30, 2026
ce4850a
feat: modernize PostgreSQL introspection provider
svetch Jan 30, 2026
721abd7
feat: modernize SQLite introspection provider
svetch Jan 30, 2026
ca7167c
fix: improve relation field naming and default action handling
svetch Jan 30, 2026
58a238e
feat: track imports and auto-format during db pull
svetch Jan 30, 2026
5720c91
test: update pull tests to reflect naming and formatting improvements
svetch Jan 30, 2026
b4a6651
fix(cli): refactor PostgreSQL type casting and fix index order
svetch Jan 30, 2026
84d5afc
fix(cli): filter out auto-generated MySQL indexes
svetch Jan 30, 2026
3937a62
test(cli): support datasource extras in test utils
svetch Jan 30, 2026
b52aa5b
fix: address PR comments
svetch Jan 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
"./package.json": "./package.json"
},
"dependencies": {
"@dotenvx/dotenvx": "^1.51.0",
"@zenstackhq/common-helpers": "workspace:*",
"@zenstackhq/schema": "workspace:*",
"@zenstackhq/language": "workspace:*",
"@zenstackhq/orm": "workspace:*",
"@zenstackhq/sdk": "workspace:*",
Expand Down
25 changes: 21 additions & 4 deletions packages/cli/src/actions/action-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { loadDocument } from '@zenstackhq/language';
import { isDataSource } from '@zenstackhq/language/ast';
import { type ZModelServices, loadDocument } from '@zenstackhq/language';
import { type Model, isDataSource } from '@zenstackhq/language/ast';
import { PrismaSchemaGenerator } from '@zenstackhq/sdk';
import colors from 'colors';
import fs from 'node:fs';
Expand Down Expand Up @@ -41,8 +41,22 @@ export function getSchemaFile(file?: string) {
}
}

export async function loadSchemaDocument(schemaFile: string) {
const loadResult = await loadDocument(schemaFile);
export async function loadSchemaDocument(
schemaFile: string,
opts?: { keepImports?: boolean; returnServices?: false },
): Promise<Model>;
export async function loadSchemaDocument(
schemaFile: string,
opts: { returnServices: true; keepImports?: boolean },
): Promise<{ model: Model; services: ZModelServices }>;
export async function loadSchemaDocument(
schemaFile: string,
opts: { returnServices?: boolean; keepImports?: boolean } = {},
) {
const returnServices = opts.returnServices || false;
const keepImports = opts.keepImports || false;

const loadResult = await loadDocument(schemaFile, [], keepImports);
if (!loadResult.success) {
loadResult.errors.forEach((err) => {
console.error(colors.red(err));
Expand All @@ -52,6 +66,9 @@ export async function loadSchemaDocument(schemaFile: string) {
loadResult.warnings.forEach((warn) => {
console.warn(colors.yellow(warn));
});

if (returnServices) return { model: loadResult.model, services: loadResult.services };

return loadResult.model;
}

Expand Down
381 changes: 377 additions & 4 deletions packages/cli/src/actions/db.ts

Large diffs are not rendered by default.

Loading
Loading