W
Wasp•3mo ago
Sven

I changed the name of my app and some domain settings

Does chaning the name of my app result in loss of database entries in development and also in production? When i changed this i got this error:
[ Server ] GET /auth/me 500 13.951 ms - 1330
[ Server!] PrismaClientKnownRequestError:
[ Server!] Invalid prisma.session.findUnique() invocation:
[ Server!]
[ Server!]
[ Server!] The table public.Session does not exist in the current database.
[ Server ] GET /auth/me 500 13.951 ms - 1330
[ Server!] PrismaClientKnownRequestError:
[ Server!] Invalid prisma.session.findUnique() invocation:
[ Server!]
[ Server!]
[ Server!] The table public.Session does not exist in the current database.
This is what i changed:
app NAME {
wasp: {
version: "^0.14.0"
},
app NAME {
wasp: {
version: "^0.14.0"
},
I fixed the error with wasp db migrate-dev but now my whole dev database is empy and i am scared this will also happen in my production.
7 Replies
kapa.ai
kapa.ai•3mo ago
Hi @Sven. 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 the knowledge sources, I can address your concerns about database entries and the error you encountered. Let me break it down for you: 1. Database entries and app name change: Changing the name of your app in the app declaration in your .wasp file should not directly result in the loss of database entries, either in development or production. The app name change itself doesn't affect the database schema or its contents. 2. Error you encountered: The error you saw suggests that the Session table was not found in your database. This could happen if there were changes to your database schema that weren't properly synchronized with your actual database. 3. Fixing with wasp db migrate-dev: Running wasp db migrate-dev is indeed the correct step to synchronize your database schema with your current entity definitions CLI Reference (https://wasp-lang.dev/docs/general/cli#database-commands). This command generates and applies any pending migrations to your development database. 4. Empty development database: If your development database is now empty after running wasp db migrate-dev, it's possible that the migration process created a new database or reset the existing one. This can happen if there were significant changes to your schema or if the previous database state was incompatible with the new schema. 5. Production database concerns: Your concern about the production database is valid. However, the production database is handled differently. In a deployed app, Wasp runs migrations on every application start using prisma migrate deploy Github Issue (https://github.com/wasp-lang/wasp/issues/215). This means that any new migrations will be applied, but existing data should be preserved unless the migrations explicitly modify or delete data. To ensure the safety of your production data: 1. Always test your migrations thoroughly in a development or staging environment before deploying to production. 2. Consider backing up your production database before applying significant changes. 3. If possible, use a staging environment that mirrors your production setup to test the migration process. For future development, to avoid unexpected database issues: 1. Run wasp db migrate-dev whenever you make changes to your entity definitions in the .wasp file. 2. Keep an eye on the generated migrations in your project's migrations folder to understand what changes are being applied. 3. If you need to make complex schema changes, consider creating custom migrations to handle data transformations safely. Remember, while wasp db migrate-dev is safe to use in development, be cautious with production databases. Always have a backup and a rollback plan when applying changes to production. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Sven, 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?
Sven
SvenOP•3mo ago
@kapa.ai i set a WASP_SERVER_URL ta custom one: api.custom.com. How do i make my client make requests to it e.g: api.custom.com/auth/me
kapa.ai
kapa.ai•3mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- To make your client send requests to your custom server URL (api.custom.com in your case), you need to set the REACT_APP_API_URL environment variable for your client. This variable tells the Wasp client where to send API requests. Here's how you can do it: 1. For development: Create a .env.client file in your project root (if it doesn't exist already) and add the following line:
REACT_APP_API_URL=<https://api.custom.com>

REACT_APP_API_URL=<https://api.custom.com>

Make sure to use <https://> if your API is served over HTTPS. 2. For production: When deploying your app, you need to set the REACT_APP_API_URL environment variable in your deployment environment. The exact method depends on your hosting provider. After setting this variable, your client will automatically use it to construct API request URLs. For example, a request to /auth/me will be sent to <https://api.custom.com/auth/me.> Here are some important points to keep in mind: 1. The REACT_APP_API_URL should not have a trailing slash. If you include one, it might lead to double slashes in the URLs, causing issues Github Issue (https://github.com/wasp-lang/wasp/issues/332). 2. Make sure your WASP_SERVER_URL (on the server side) and REACT_APP_API_URL (on the client side) are consistent to avoid CORS issues Discord Thread (https://discord.com/channels/686873244791210014/1217758453326680095). 3. If you're using Wasp's built-in authentication, ensure that you've also updated the WASP_WEB_CLIENT_URL on your server to match your client's URL. This is crucial for CORS configuration Fly.io Deployment Docs (https://wasp-lang.dev/docs/advanced/deployment/cli#using-a-custom-domain-for-your-app). 4. You can verify that the client is using the correct API URL by checking the config.apiUrl value in your client code Client Configuration Docs (https://wasp-lang.dev/docs/advanced/accessing-app-config#client-configuration-object):
import { config } from 'wasp/client'
console.log(config.apiUrl)

import { config } from 'wasp/client'
console.log(config.apiUrl)

By following these steps, your client should now make requests to your custom server URL (api.custom.com). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Sven, 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?
Sven
SvenOP•3mo ago
@kapa.ai i use fly how can i point my cleint to my custom domain server
kapa.ai
kapa.ai•3mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- To point your client to your custom domain server when using Fly.io, you need to follow these steps: 1. Set up your custom domain for your server on Fly.io: First, make sure you've set up your custom domain for your server app on Fly.io. You can do this by following the instructions in the Fly.io custom domain documentation (https://wasp-lang.dev/docs/advanced/deployment/cli#using-a-custom-domain-for-your-app). 2. Update the WASP_WEB_CLIENT_URL environment variable: After setting up your custom domain, you need to update the WASP_WEB_CLIENT_URL environment variable for your server app. This is crucial for CORS configuration. You can do this by running:
wasp deploy fly cmd --context server secrets set WASP_WEB_CLIENT_URL=<https://yourclientdomain.com>

wasp deploy fly cmd --context server secrets set WASP_WEB_CLIENT_URL=<https://yourclientdomain.com>

Replace yourclientdomain.com with your actual client domain. 3. Set the REACT_APP_API_URL for your client: When building your client for production, you need to set the REACT_APP_API_URL to point to your custom server domain. If you're using the Wasp CLI for deployment, you can do this by running:
REACT_APP_API_URL=<https://api.yourcustomdomain.com> wasp deploy fly deploy

REACT_APP_API_URL=<https://api.yourcustomdomain.com> wasp deploy fly deploy

Replace api.yourcustomdomain.com with your actual custom server domain. 4. Verify the configuration: After deployment, you can verify that your client is using the correct API URL by checking the config.apiUrl value in your client code:
import { config } from 'wasp/client'
console.log(config.apiUrl)

import { config } from 'wasp/client'
console.log(config.apiUrl)

This should output your custom server domain. Remember to always use <https://> in your URLs if your server is served over HTTPS, which is recommended for production environments. By following these steps, your client should now make requests to your custom domain server when deployed on Fly.io. Fly.io Custom Domain Documentation (https://wasp-lang.dev/docs/advanced/deployment/cli#using-a-custom-domain-for-your-app) Wasp Deployment Documentation (https://wasp-lang.dev/docs/advanced/deployment/manually#environment-variables) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Sven, 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?
Filip
Filip•3mo ago
Hello again @Sven 😄 I'm guessing you're using wasp db start. This is Wasp's helper tool for a dev database and Wasp picks a name derived from your app's name. So, when you change your app's name, wasp start db starts using a different database. In production, you'll have a proper database and a proper database url. So, you're database is completely safe from all the changes you do in the app (unless you accesss it and delete stuff).
Sven
SvenOP•3mo ago
ahh cool thanks alot! ✅ SOLVED

Did you find this page helpful?