W
Waspβ€’4w ago
cking!M

Iterating on my app post deployment

I have built my app successfully with "wasp build" and I am trying to add some new features to redeploy. After running wasp start db and wasp start to test my changes, it seems to delete a bunch of database tables. I am worried because I do need these tables in my app. What did I do wrong? How do I resolve this? 🐝 --- Setting up database... ----------------------------------------------------- [ Db ] [-] Removed tables [ Db ] - Client [ Db ] - Campaign [ Db ] [ Db ] [*] Changed the Campaign table [ Db ] [-] Removed foreign key on columns (userId) [ Db ] [-] Removed foreign key on columns (clientId) [ Db ] [ Db ] [*] Changed the Client table [ Db ] [-] Removed foreign key on columns (userId) [ Db ] Environment variables loaded from .env [ Db ] Prisma schema loaded from ../db/schema.prisma [ Db ] [ Db ] βœ” Generated Prisma Client (v5.19.1) to ./../../../node_modules/@prisma/client in 440ms [ Db ] βœ… --- Database successfully set up. ---------------------------------------------- 🐝 --- Building SDK... ------------------------------------------------------------ βœ… --- SDK built successfully. ---------------------------------------------------- βœ… --- Your wasp project has successfully compiled. ------------------------------- πŸ‘€ --- [Warning] Your wasp project reported following warnings during compilation: --- - Your Prisma schema does not match your database, please run wasp db migrate-dev`.
8 Replies
kapa.ai
kapa.aiβ€’4w ago
Hi @cking!M. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided in your question, it seems you've encountered an issue with database schema changes after making modifications to your Wasp app. Let's address this step by step: 1. The warning message you're seeing is actually expected behavior when you've made changes to your app's data model. Wasp is detecting that your Prisma schema (which defines your database structure) no longer matches your actual database Github Issue #214 (https://github.com/wasp-lang/wasp/issues/214). 2. The removal of tables and foreign keys you're seeing is not actually deleting data from your production database. This is just Wasp showing you the changes that need to be applied to sync your database with your new schema Github Issue #1486 (https://github.com/wasp-lang/wasp/issues/1486). 3. To resolve this and apply your changes, you need to run the following command:
wasp db migrate-dev

wasp db migrate-dev

This command will create a new migration based on your schema changes and apply it to your development database Wasp CLI Reference (https://wasp-lang.dev/docs/general/cli#database-commands). 4. After running the migration, you should be able to start your app without seeing the warnings about mismatched schema. 5. For your production deployment, Wasp automatically runs migrations when the app starts, so you don't need to manually run migrations in your production environment Discord Support Thread (https://discord.com/channels/686873244791210014/1217295340785635418). Remember, it's a good practice to run wasp db migrate-dev after making changes to your data model (entities in Wasp) to keep your local development database in sync with your schema Github Issue #248 (https://github.com/wasp-lang/wasp/issues/248). If you're concerned about data loss in your production environment, you might want to consider implementing forward-only migrations (no renaming, no dropped columns) as suggested by a community member in this Github Issue #215 (https://github.com/wasp-lang/wasp/issues/215). This approach allows for safer database updates in production scenarios. If you continue to face issues after running the migration, you may want to try running wasp clean to remove all generated code and cached artifacts, and then rebuild your project Wasp CLI Reference (https://wasp-lang.dev/docs/general/cli#project-commands). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @cking!M, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
cking!M
cking!MOPβ€’4w ago
@kapa.ai will running wasp db migrate-dev again build the database based on what is in my prisma.schema file?
kapa.ai
kapa.aiβ€’4w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Yes, running wasp db migrate-dev will indeed update your database schema based on what is defined in your Prisma schema file. Here's what this command does: 1. It compares your current Prisma schema (which reflects the entities defined in your Wasp file) with the current state of your database Wasp CLI Reference (https://wasp-lang.dev/docs/general/cli#database-commands). 2. If there are any differences, it generates a new migration script to bring the database in line with your schema Wasp Entities Documentation (https://wasp-lang.dev/docs/data-model/entities#working-with-entities). 3. It then applies this migration to your development database, effectively synchronizing your database with the current state of your schema Wasp Tutorial (https://wasp-lang.dev/docs/tutorial/entities). Here's the process in more detail:
1. Create/update some Entities in your `.wasp` file.
2. Run `wasp db migrate-dev`. This command syncs the database model with the Entity definitions in your `.wasp` file. It does this by creating migration scripts.
3. Migration scripts are automatically placed in the `migrations/` folder. Make sure to commit this folder into version control.
1. Create/update some Entities in your `.wasp` file.
2. Run `wasp db migrate-dev`. This command syncs the database model with the Entity definitions in your `.wasp` file. It does this by creating migration scripts.
3. Migration scripts are automatically placed in the `migrations/` folder. Make sure to commit this folder into version control.
It's important to note that this command is meant for development purposes. For production deployments, Wasp handles migrations automatically when the app starts Discord Support Thread (https://discord.com/channels/686873244791210014/1217295340785635418). Remember, if you've made significant changes to your schema, it's always a good idea to review the generated migration scripts before applying them, especially if you're working with a database that contains important data. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @cking!M, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Jacky
Jackyβ€’4w ago
No too familiar with Wasp, but how do I change the db schema from within wasp without the db command?
miho
mihoβ€’4w ago
@cking!M the output is normal to see, it's just Prisma diffing the database to determine if migrations are needed. In short, you run wasp db migrate-dev after you change the schema.prisma file. The migrations dir contains the migrations need to update your database to the latest state. It happens right away while you develop stuff and also when you deploy, it updates your production database. I'm not sure what you mean by "without the db command"? What are you trying to achieve and what did you try so far?
miho
mihoβ€’4w ago
To get more familiar with Wasp, I recommend going through the tutorial: https://wasp-lang.dev/docs/tutorial/create
1. Creating a New Project | Wasp
You'll need to have the latest version of Wasp installed locally to follow this tutorial. If you haven't installed it yet, check out the QuickStart guide!
Jacky
Jackyβ€’4w ago
Makes a lot more sense ty Also, Is it possible to add my own Saml SSO easily to Open Saas Template in Wasp?
miho
mihoβ€’4w ago
Open Saas is based on Wasp, I'd really recommend checking Wasp's docs and see what it can do and which providers it supports. If you want to go full custom, we have an example for Spotify auth: https://gist.github.com/infomiho/3c63de7d53aba59d6293bcb59501a029
Gist
Implementing custom OAuth provider with Wasp 0.14.1+ (Spotify in th...
Implementing custom OAuth provider with Wasp 0.14.1+ (Spotify in this case) - .env.server
Want results from more Discord servers?
Add your server