Can I create tables at runtime?

Is it possible to create a user-specific schema and then generate tables within that schema when a user signs up?
4 Replies
Cris | Mailspace
Cris | Mailspace12mo ago
any solutions on this?
Angelelz
Angelelz11mo ago
This is an interesting problem. The way drizzle is currently setup is, it needs to have an schema to be able to infer all your types If you're creating tables, you should have the the shape of those tables already defined in your schema even if they don't exits I might be able to help with the workflow but I'd need to have more insights on the use case.
wolverine
wolverine11mo ago
Hi, new to the discussion here. I made an accounting app using sveltekit and fastapi as backend. I had a main database which contained information regarding business i.e name, address, tax identifiers, sales identifiers, govt regulation identifiers e.t.c. Whenever a new business was created in the main database a new database associated with that particular business was created which contained tables for voucher entries, sales orders, purchase, inventory e.t.c. This can be achieved in a single sqlite db as well but lookup times are significantly better when each business has its own database which may contain thousands of records and its easier to keep backup of the data as well. I am planning to migrate my entire stack to javascript (drop fastapi and sqlmodel) as working with a separate fastapi backend litters my code with uncountable fetch requests. Sveltekit provides a super simple action api and if somehow i can create tables from my app for each individual business I will be a step closer to my goal. @Angelelz any thoughts?
Angelelz
Angelelz11mo ago
Drizzle ORM - Goodies
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Want results from more Discord servers?
Add your server