Laravel database migration error solution

Source: Internet
Author: User
Tags autoload
Laravel database migration reports an error.

Use the migrate: make command of the Artisan command line to create a migration: (use in command line mode)

php artisan migrate:make create_users_table

All the migration files are stored in the app/database/migrations folder. the files are named with timestamps to facilitate the Laravel framework to define the order of these files by time.

You can use the -- path option during migration creation to specify the path for storing the migration file. This path is the relative path of the root directory of your installation framework:

php artisan migrate:make foo --path=app/migrations

The -- table and -- create options are used to specify the table name and whether to create a new table:

php artisan migrate:make add_votes_to_user_table --table=usersphp artisan migrate:make create_users_table --create=users

Run data migration run all migration (keep all your tables up-to-date)
php artisan migrate

Run all migration under a path (specify the path of the migration file)
php artisan migrate --path=app/foo/migrations

Run all the migrations under a certain package (used to install or upgrade the corresponding database of an extension package)
php artisan migrate --package=vendor/package

Note:If you receive a "class not found" error while running the migration, try to run the composer dump-autoload command.

Use data migration forcibly in the production environment

Some migration operations are destructive and may cause you to lose the original data in the database. to prevent unnecessary damages caused by running such commands, you are asked whether you are sure to do so. if you want to run such a command without a prompt, you can use the -- force option:

php artisan migrate --force

Rollback data migration (even if rollback is performed, the original data is damaged and only the table structure can be rolled back. therefore, do not use this function as a life-saving tool). rollback the last Migration
php artisan migrate:rollback


Don't worry: run composer dump-autoload

Try again, OK. see the figure below.

Roll back all migration
php artisan migrate:reset

Roll back all migration and re-run data migration
php artisan migrate:refreshphp artisan migrate:refresh --seed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.