@mallory_cormier
To rollback a migration in CodeIgniter, you can use the following steps:
- Locate the migration file you want to rollback in the ‘application/migrations’ folder.
- Inside the migration file, find the ‘down’ function. This function should contain the code to reverse the changes made in the ‘up’ function of the migration.
- Run the migration rollback command in your terminal or command prompt:
1
|
php index.php migrate [version_number]
|
Replace [version_number] with the version number of the migration you want to rollback.
- Once you run the command, the ‘down’ function in the migration file will be executed, reversing the changes made in the ‘up’ function.
- Verify that the rollback was successful by checking the database to see if the changes have been reverted.
- You can also rollback all migrations by running the following command:
1
|
php index.php migrate version 0
|
This will rollback all migrations to their initial state.
By following these steps, you can easily rollback a migration in CodeIgniter.