Prince
Prince

Reputation: 1192

Unable to run php artisan migrate in Laravel

I am new to laravel and while working I created a new migration. After running the command php artisan migrate, the migration was successful. I then went back to the previous created migration and added some new fields. When I run back the command php artisan migrate, I was receiving the message Nothing to migrate. I was then supposed to run the command php artisan migrate:refresh for the changes to be applied but I did not want to rollback some migrations so I went to those migrations and I modified the last method as following

/**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        // The line below has been commented to prevent rollback
        // Schema::drop('table-name');
    }

Since then when I run php artisan migrate I get the following error: [Symfony\Component\Debug\Exception\FatalErrorException] Class 'Carbon' not found I have run composer update, composer dump-autoload, composer clear-cache, php artisan migrate:refresh, php artisan migrate:rollback, php artisan migrate:reset

Kindly help me solve this problem.

Upvotes: 0

Views: 730

Answers (2)

shock_gone_wild
shock_gone_wild

Reputation: 6740

I would not recommend to comment some lines in the migration's down method. Generally the down() method should always undo the operations made in the up() method.

If you want to add some fields to an existing table and don't want to loose some data by doing a refresh, then just create another migration and specify the table you want to modify. For example:

php artisan make:migration add_some_fields_to_users --table=users

You could also consider using Database Seeds so you can refresh your migrations and then seeding the database with data again. This is very powerful during development stage.

For you Carbon issue most likely the answer from @Sanrekula is what your are looking for.

Upvotes: 1

santosh
santosh

Reputation: 118

In your migration classes or scripts, you have used Carbon class, but forgot to import/include.

Add

use Carbon/Carbon;

in your migration scripts where you have used Carbon class and run migrations.

ref link: http://laravel.io/forum/03-12-2014-class-carbon-not-found

Upvotes: 2

Related Questions