How do you structure your schemas?

Hi, how do you structure your schemas? I'm building a larger app, and the schemas are growing, so it doesn't make sense to have all tables in one schema. However, creating multiple schemas as multiple files (screenshot included) is also something that I'm not in favor of. Thanks
No description
9 Replies
Marťafiixek
MarťafiixekOP11mo ago
I've thought about grouping similar tables such as companies and halls or hall separators to one file that exports these three tables
amgau
amgau11mo ago
I have a "db" folder, inside that I have things grouped by domain inside of a single file
Marťafiixek
MarťafiixekOP11mo ago
What do you mean grouped by domain? Sorry, relational databases are not my strong point
amgau
amgau11mo ago
Just logical groupings, and then core business related things are in index.ts so I have users.ts with auth stuff, preferences, etc.
Marťafiixek
MarťafiixekOP11mo ago
Oh get it
amgau
amgau11mo ago
index.ts with categories, transactions, accounts, invoices, etc.
Marťafiixek
MarťafiixekOP11mo ago
Makes sense
amgau
amgau11mo ago
don't know if it makes sense for most, but for me it kinda does, especially when importing import user from '~/db/user.ts" import {account, invoice} from '~/db' might make more sense to just make index a barrel, but I haven't put too much thought into it
Marťafiixek
MarťafiixekOP11mo ago
Thanks for the input I can now choose approach in peace as I have at least a opinion from someone else 😄 Also, suppose I have a many to many relation between users and projects. I need to create a JOIN table, in which file should I create the JOIN table and relations. Under users.ts or projects.ts? Or should I have a separate file for JOIN tables?
Want results from more Discord servers?
Add your server