DT
Drizzle Teamsignificantotter

Nesting sqlite drizzle into a deeper location in my ts app, difficulties with src/ vs dist/

Hey! I'm very new to drizzle and trying to set up a very small drizzle instance for a service that reads a whole pile of json files and acts as a simple read-only information store. I got most of the setup to work. I have it at a location
src/
--services/
----this-service/
------drizzle.config.ts
------sqlite.db
------schema.ts
------this-service.db.ts
src/
--services/
----this-service/
------drizzle.config.ts
------sqlite.db
------schema.ts
------this-service.db.ts
I have some the command in my package.json
"migrate:this-service": "cd ./src/services/this-service && drizzle-kit push:sqlite"
"migrate:this-service": "cd ./src/services/this-service && drizzle-kit push:sqlite"
This works, but it appears that once I build, the sqlite isn't copied over to the /dist directory. When I then try to call this-service.db.ts, after instantiating drizzle on sqlite in its directory, it doesn't see any of the proper tables from the schema in the sqlite.db file. Is there a way to make this work? Or do I have to move this all to the root directory? One option would be is if there are importable drizzle kit functions to replicate the CLI options. I didn't see that in the documentation. Is that possible?
Angelelz
Angelelz247d ago
You need to tell your build tool to copy whatever you need to your dist folder Most likely you need to add the db filetype to your include field in your tsconfig.json
significantotter
significantotter247d ago
hm, typescript is annoying about this. They don't like to copy non ts assets. https://github.com/microsoft/TypeScript/issues/30835 But that's very helpful direction, and I'm looking at doing that now
GitHub
Typescript compiler --copy-files option to copy non-typescript file...
Search Terms typescript tsc copy files Suggestion The typescript compiler should have an option to copy non-compiled files, similarly to Babel: https://babeljs.io/docs/en/babel-cli#copy-files Use C...
Angelelz
Angelelz247d ago
You could treat your db file like the assets folder, have a DB folder for your database only, at the root, and point to it from both your src and your dist
significantotter
significantotter247d ago
True. I'm just trying to contain it to the service. I had considered that if I don't have other options. I'm currently using objection + pgsql for the main db work here. I just wanted a small embedded read store for this service. I plan to eventually migrate from objection to drizzle for that pg database, so I wanted to leave this one more encapsulated But yeah! Fixed it with a copyfiles tool to get the asset over. Now I'm trying to get drizzle kit studio to work with it. I'm running it in my dist directory. I can open the sqlite file and see the data. But drizzle kit studio shows an empty db Hmm... I think I see the issue when I run drizzle kit studio in the /dist directory, my schema is still referenced as './schema.ts' which fails against the compiled code. So it sees db url, but can't find the schema hm, maybe I have no choice but to move it to the top level. Would that cause issues for a later drizzle pg database in the same env as the drizzle sqlite database?
Angelelz
Angelelz247d ago
You can pass a different configuration
significantotter
significantotter247d ago
ah! That's helpful
Want results from more Discord servers?
Add your server
More Posts
syntax highlighting not workingI reinstalled the node_modules multiple times and it didnt fix my problem. This isnt suposed to lookPrepare raw sql query (Postgres)Hi, I need to do a recursive query, so I think I need to use the magic sql operator to build it. Is packing migration files with the libraryhey there, I'm trying to use `migrate` inside from a library consumer (i.e I have a `@mycompany/db-lAny way to invoke a SQL function?For ex: lets say I declare a SQL function `CREATE OR REPLACE FUNCTION do_something()` how do i invoHow to include array literals in raw sql?I have an input array used for an order by using the array_position function - rather than passing tMySQL Table SchemasI need to generate the following structure of tables: `1. Sales 2.Sales ....` Currently if I use wany way to automatically cast numeric types on retrieval?I have a numeric field in a video table: ``` export const VideoTable = pgTable('videos', { id: uuiQuery in drizzle doesn't work## Error: ```console DrizzleError: No fields selected for table "usersToGroups" ("users_groups") ``Cannot read properties of undefined (reading 'referencedTable')Seemingly getting this error out of nowhere. I believe it's related to the relations I defined, but Relational query builder in mysql?I cant find anything about how to implement this. Am I blind or is this impossible?TransactionRollbackErrorNeed some help understanding TransactionRollbackError... Is this error saying the `tx.rollback()` fPostgresError: null value in column "id" of relation "pairs" violates not-null constraintHello, I am fairly new to Drizzle and working with databases, so I am running into a problem that I OnConflictDoNothing with mysqlHi everyone, I want to use the on conflict do nothing method described here: https://orm.drizzle.teadrizzle-kit introspect reorder tablesHere is the case: - I have a remote database. I made a backup and restore it locally - I ran: drizzMigration custom loggerHey there, I'm want to run migration as part of my CI/CD, and would have liked the output of the `miwhy do snapshots not have the same name as the migrations?Hey, loving dirzzle so far. Hit a snag recently. Me and my friend are collaborating on a project. Help with improving database queryHello, I am seeking advice on how to improve a database query I am currently working with. My objectTypescript types for relational queries with neon dbHey, I am having an issue with typescript types for relational queries with drizzle and neon db. Det.onUpdateNow() for postgresql?is that possible?Migrating in JS & JSON (no filesytem)👋 we're big fans (and sponsors) of Drizzle at Val Town. We use it internally and love it. We just