Then let's run "php artisan migrate" to execute those files....
So... There is only one table created in database but actually we were executing 3 migrations files that we created before. Why is that happened? because 2 files contains no tables... :D only migration_2 files has table and column inside...
Ooops... We have executed php artisan migrate before, so there is nothing to migrate... So we know that migrate is only work for new migration file. So for the old one, we can use three options, migrate:refresh,reset, and rollback :
We will try all of those commands one by one.. :D
First let's try rollback.....So type php artisan migrate:rollback
Rollback is almost same with reset... It will remove all of our last migration table. So our DB will contain just migration table. Then run "php artisan migrate" again aaand....
So...be carefull when using this rollback command because it will gonna delete all of your data... :D
Next... Let's try migrate:reset...
aaand... waaaw... database is empy again.. :v
So what's the different between rollback and reset...??? mmm... let's find out later.. :)
Then let's see migrate:refresh....
So refresh is using rollback first and then migrate all of the migration file... :)
One thing to note that if have put some data in our database, the refresh will also delete all data in database because it's using rollback... So becarefull with this one too.. :v
So how to add new column without deleting our data...??? This will be covered in the next post...:)
See yaaaa......
Go to the next post....
No comments:
Post a Comment