FEAT: Enhanced Introspection - store types/function/etc. metadata #3151
austinm911
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I haven't used the
introspect
feature very much, but in my limited use I'm wondering if some improvements can be made to thefeature, namely around importing types, default functions, and so forth.
I understand introspect was likely planned for users who had no drizzle configuartion setup but had a database already created, so users using
introspect
can easily import and get started.However for my use case, I have a database I'm using in different projects. I have noticed in my limited use that I have to go back to my source schema to copy over types/default functions used. So in effect, I should have just copy and pasted my original files.
This feature idea is inspired from Windmill - which has a really robust way of syncing between remote and local code configuration - see Local development | Windmill
Problems
If you have any extra options, types, etc defined in a source drizzle schema and you introspect it to other projects, you will lose this extra information.
For example, with SQLite
Field Options
Source:
field: text('field', { mode: 'json' }),
Introspected:
field: text("field")
Default Functions
Source:
createdOn: text("created_on").notNull().$defaultFn(() => new Date().toISOString())
Introspected:
createdOn: text("created_on")
Proposed Solution
Reason for Improvement
schema.ts
fileUnknowns
id: text().primaryKey().notNull().$defaultFn(nanoid),
, where nanoId is a function imported from another file. How should this be handled? Ideally, when user introspects, the functions imported could be bundled and imported into autils.ts
file alongsideschema.ts
andrelations.ts
Beta Was this translation helpful? Give feedback.
All reactions