Create tables for local development

Hi! I'm trying to use a local instance of a PostgreSQL database (via Docker) so that I can make queries without hitting my production database. I'll need to create the tables themselves inside the database before I can make these queries. Is there a way I can do that from what Prisma generates? I have the Prisma schema and the associated models (e.g. User, Session, Account), but I would need to translate it to raw SQL statements and add them via a Docker initialization script. I know there are already raw SQL files for the migrations, but those are "step by step" rather than the final / most up to date results. I could do this by hand, but this means that any time I update the schema, I would have to manually edit the initialization script as well (which would be prone to error). Thanks!
3 Replies
chicken dinner
chicken dinnerOP•3w ago
Further looking into this, seems like prisma migrate diff --script might be something that would work? prisma migrate diff --from-empty --to-url <URL> --script seems like it's correct, but if someone could confirm that would be splendid!
chicken dinner
chicken dinnerOP•3w ago
Thanks Raphael! I'll try that out 🙂
Want results from more Discord servers?
Add your server