Skip to content

Chore: refactor templates and centralize validations - #35

Merged
VoidClancy merged 1 commit into
masterfrom
postgres-defaults
Jul 12, 2026
Merged

Chore: refactor templates and centralize validations#35
VoidClancy merged 1 commit into
masterfrom
postgres-defaults

Conversation

@VoidClancy

Copy link
Copy Markdown
Owner

1 - Database-Native Type Centralization:
- Define schema/native_types.go, mapping Prisma native types to SQL data types, Go runtime types, and required database extensions
- Replace long hardcoded switch blocks in nativeTypeToSQL() and unsupportedToGoType() with lookups into the new central types map
- Dynamically resolve types in injectRequiredExtensions() using the same central map

2 - Client & Embedded Runtime Refactoring:
- Create a unified runtime template (runtime.gotpl) containing dialects, DBTX, custom errors, and flat validations
- Consolidate and strip all external runtime dependencies to keep the generated client completely self-contained
- Wrap net and hstore package imports and validation methods in conditional blocks (hasNetAnywhere and hasHstoreAnywhere), emitting them only when required by the schema
- Optimize code generator templates (model_create.gotpl) to use generalized loops (ToRowMap) and flat validations instead of duplicating field loops.

3 - Testing & Automation Improvements:
- Implement a bidirectional schema switcher in prepareSchema.js to back up and restore PG-specific syntax when switching dialects.
- Add SQLite (test-sqlite), PostgreSQL (test-pg), and double-engine (test-dbs) test targets to the makefile.
- Write a multi-step schema evolution test suite (evolution_test.go) that simulates database migrations (optional fields, defaults, unique checks, relationships) inside a sandbox

@VoidClancy VoidClancy self-assigned this Jul 12, 2026
@VoidClancy
VoidClancy merged commit fae416b into master Jul 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant