Laravel迁移以奇怪的方式运作

Jac*_*n J 1 mysql laravel

我已经删除了测试数据库,然后我想使用已保存的迁移创建新数据库:

2017_03_01_000000_create_api_table.php
2017_03_06_000000_create_beeline_calls.php
2017_03_13_000000_modify_beeline_emails.php
2017_03_14_000000_interactive_forms.php
2017_03_16_000000_model_instances.php
2017_03_24_000000_create_objects.php
2017_03_24_000001_create_objects_tables_v2.php
2017_03_24_000003_make_comments_without_users.php
2017_03_27_000000_add_processed_to_announcements.php
2017_03_29_000000_create_ads_channels.php
2017_03_29_000001_announcement_client.php
2017_04_06_000000_create_filters.php
2017_04_07_000000_create_new_input_types.php
Run Code Online (Sandbox Code Playgroud)

我跑的时候 php artisan migrate --pretend

  [Doctrine\DBAL\Schema\SchemaException]                                                                  
  There is no column with name 'creator_id' on table 'application_model_instance_announcement_comments'.
Run Code Online (Sandbox Code Playgroud)

但是要运行的第一个迁移文件是 2017_03_01_000000_create_api_table.php

为什么它不是从一开始就运行的?数据库为空,migrations表为空.据我所知,Laravel应按字母顺序运行迁移文件.

lew*_*s4u 6

为了能够执行php artisan migrate创建列的表,不能包含与迁移中相同的列名.您必须先使用此命令删除它

php artisan migrate:refresh
Run Code Online (Sandbox Code Playgroud)

你正在这样做

php artisan migrate:rollback
php artisan migrate
Run Code Online (Sandbox Code Playgroud)

有2个命令 php artisan migrate:refresh

在迁移中更改某些内容时,始终运行以下命令:

php artisan cache:clear
php artisan view:clear
php artisan route:clear
composer dump-autoload
Run Code Online (Sandbox Code Playgroud)

它将清除所有旧的东西,应该顺利运行!