W
Wasp-langRicardo Batista

Where to see migration files?

I have messed up one migration (because I had to delete my local code), and now I don't know where to access the migration files. They are generated at build time, and stored on .wasp, but where are they coming from? I need to regenerate the previous files (I can access the previous migrations by the current server code).
kapa.ai
kapa.aiβ€’19d ago
Hi @Ricardo Batista. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The migration files for your Wasp project are located in the migrations/ directory at the root of your Wasp project. These files are not provided to the Generator at all, instead, they are copied by certain commands in the CLI. If you delete the migrations/ directory from the Wasp project root directory and run wasp start or wasp build, any previously generated migrations/ directory will remain in the generated code. If you need to regenerate the previous files, you might need to manually recreate the migrations based on the current server code. Unfortunately, Wasp does not currently provide a built-in way to regenerate deleted migration files. For future reference, it's important to be careful when handling migration files as they are crucial for the correct operation of your database. If you're using a version control system like git, it's a good practice to include your migration files in it. This way, you can always revert to a previous state if something goes wrong. For more details, you can refer to this Github issue (https://github.com/wasp-lang/wasp/issues/211) discussing the handling of migration files in Wasp. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Ricardo Batista, 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?
Ricardo Batista
Ricardo Batistaβ€’19d ago
@kapa.ai I realised the migration folder is not part of .wasp, so it doesn't get rebuilt
kapa.ai
kapa.aiβ€’19d ago
Let me check the knowledge base for you. One moment! :books: ---------------------- You're correct. The migrations/ directory is not part of the .wasp directory. Instead, it resides in the root directory of your Wasp project. The migrations/ directory contains the database migration files that Prisma uses to update your database schema. When you run wasp start or wasp build, Wasp does not automatically regenerate the migrations/ directory if it has been deleted. This is because the migration files are typically created manually by the developer when making changes to the database schema, and they represent a history of schema changes over time. If you've accidentally deleted your migrations/ directory, you'll need to manually recreate the necessary migration files based on your current database schema. Unfortunately, Wasp does not currently provide a built-in way to regenerate deleted migration files. For more information, you can refer to this Github issue (https://github.com/wasp-lang/wasp/issues/211) discussing the handling of migration files in Wasp. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Ricardo Batista, 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?
Ricardo Batista
Ricardo Batistaβ€’19d ago
@kapa.ai how do I reset the database to reapply the migrations?
kapa.ai
kapa.aiβ€’19d ago
Let me check the knowledge base for you. One moment! :books: ---------------------- To reset your database and reapply the migrations, you can use the wasp db reset command. This command drops all data and tables from the development database and re-applies all migrations. Here's how you can do it: 1. Run wasp db reset in your terminal. This will clear your database. 2. After resetting the database, you can reapply the migrations by running wasp db migrate-dev. Here's what the commands look like:
wasp db reset
wasp db migrate-dev
wasp db reset
wasp db migrate-dev
Please note that wasp db reset will erase all data in your development database. Make sure to backup any important data before running this command. For more details, you can refer to the Wasp CLI Reference (https://wasp-lang.dev/docs/general/cli#database-commands). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Ricardo Batista, 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?
Ricardo Batista
Ricardo Batistaβ€’19d ago
@kapa.ai wasp db reset doesn't seem to work, look what I get:
Ricardos-MacBook-Pro:app rbatista19$ wasp db reset
USAGE
wasp db <command> [command-args]

COMMANDS
start Alias for `wasp start db`.
reset Drops all data and tables from development database and re-applies all migrations.
seed [name] Executes a db seed function (specified via app.db.seeds).
If there are multiple seeds, you can specify a seed to execute by providing its name,
or if not then you will be asked to provide the name interactively.
migrate-dev Ensures dev database corresponds to the current state of schema(entities):
- Generates a new migration if there are changes in the schema.
- Applies any pending migrations to the database either using the
supplied migration name or asking for one.
OPTIONS:
--name [migration-name]
--create-only
studio GUI for inspecting your database.

EXAMPLES
wasp db migrate-dev
wasp db migrate-dev --name "Added User entity"
wasp db migrate-dev --create-only
wasp db studio
Ricardos-MacBook-Pro:app rbatista19$ wasp db reset
USAGE
wasp db <command> [command-args]

COMMANDS
start Alias for `wasp start db`.
reset Drops all data and tables from development database and re-applies all migrations.
seed [name] Executes a db seed function (specified via app.db.seeds).
If there are multiple seeds, you can specify a seed to execute by providing its name,
or if not then you will be asked to provide the name interactively.
migrate-dev Ensures dev database corresponds to the current state of schema(entities):
- Generates a new migration if there are changes in the schema.
- Applies any pending migrations to the database either using the
supplied migration name or asking for one.
OPTIONS:
--name [migration-name]
--create-only
studio GUI for inspecting your database.

EXAMPLES
wasp db migrate-dev
wasp db migrate-dev --name "Added User entity"
wasp db migrate-dev --create-only
wasp db studio
kapa.ai
kapa.aiβ€’19d ago
Let me check the knowledge base for you. One moment! :books: ---------------------- It seems like the wasp db reset command is not working as expected and instead, it's showing the help instructions. This could be due to a bug or an issue with your Wasp setup. Here are a few things you can try: 1. Make sure you're running the command in the root directory of your Wasp project. 2. Ensure that your database is set up correctly. If you're using PostgreSQL, you should have run wasp db migrate-dev before running wasp db reset. 3. Check if there are any issues with your Wasp installation. You might want to consider reinstalling Wasp. If none of these steps work, it would be best to report this issue to the Wasp community. You can do this by creating a new issue in the Wasp Github repository (https://github.com/wasp-lang/wasp/issues). Be sure to include all the relevant details, including the error message you're seeing and the steps you've taken to try to resolve the issue. For more information on how to use the Wasp CLI commands, you can refer to the Wasp CLI Reference (https://wasp-lang.dev/docs/general/cli#database-commands). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Ricardo Batista, 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?
Ricardo Batista
Ricardo Batistaβ€’19d ago
@miho looping you here, since wasp db reset doesn't seem to be working
miho
mihoβ€’18d ago
Yes sir, wasp db reset was a regression on our part, we'll readd that command in the next release of Wasp πŸ€¦β€β™‚οΈ it's already fixed, but no released yet! Let me try to help you with your problem. If you want to reapply migrations locally from scratch, I'd say the best thing to do is to delete the DB container and the DB container volume. I'm using OrbStack but the same should apply for Docker Desktop: stop the container and delete the volume (the volume is named the same as the DB container)
No description
No description
miho
mihoβ€’18d ago
Then, you'll be able to run wasp db migrate-dev and the migrations from the migrations folder would be applied from scratch πŸ™‚
Ricardo Batista
Ricardo Batistaβ€’18d ago
Thanks @miho , had to play a bit with docker commands, but I got it πŸ˜„ Thanks again!
Want results from more Discord servers?
Add your server
More Posts
File upload size limitI'm trying to implement max file upload size to the s3 bucket. I've handled the front-end but I worrAuthis there a sample bypass to login the auth while in developmentQuick Start not working?I'm following this tutorial: https://wasp-lang.dev/docs/quick-start After opening my terminal and rI cant see ubunbtu on my Linux sub system folderI just started with this programming stuff and i wanted to try my app with this new ai called magegpIs it possible to separate client and server wasp build?each time I update stuff on client, and want to push to netlify, I need to run wasp build, but it refly.io deployment errorI tried to deploy to fly.io, and I set DATABASE_URL, and I tested it can connect successfully with dfront end developers demand in job marketCan anyone please tell me about the demand of a beginner level front end developer in job market nowPassing Context for Dependency InjectionIs there a standard pattern for passing the context object for database interaction to functions? WGetting Updates to the Open SaaS Template (not working?)I am following the guide in [Getting Started](https://docs.opensaas.sh/start/getting-started/), howeCant find app and blog in my folder but it says wasp already installed.Hi everyone, ive installed Wasp but i cant find where the app and blog folder is at. It keeps says NsignupWhen defining action in main file If i dont want to use entity as i dont want to store in the db. CaStoring additional data in sessionHi everyone πŸ˜‰ I'm exploring a possibility to develop my new project in WASP which looks really awesOAuth Login Error with Google Credentials in Local EnvironmentHello everyone, I need a bit of help. In my local environment, I've correctly set up the GOOGLE_CLIETypescript not validating included relationThis is likely due to my inexperience with typescript, but I've been trying to access a related propcustomize auth UI button shapeHi, I see there is an appearance to customize the color of the auth UI, how can I change the shape oStarlight missing trailing slashStarlight's sidebar doesn't include a trailing slash ("/") at the end of the URL, leading to a 301 rSuggested cookie consent plugin?I have been trying a few cookie consent plugins for React, but none seem to work well with Wasp (e.gpaypal & other payment gateway integrationI am curious if there is guideline/template for integration of other payment gateway apart from striGoogle Tag ManagerHey everyone, I am implementing Google Tag Manager according to the instructions (attached). The <hecustom http api endpointHello. I am following some of the documents for custom http api endpoint. 8 gave an 'api foobar' def