laravel php artisan migrate 不创建新表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21350615/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 08:54:52  来源:igfitidea点击:

laravel php artisan migrate does not create a new table

phplaravellaravel-4migration

提问by

I have created a user migration and then created the table. Here is the command:

我创建了一个用户迁移,然后创建了表。这是命令:

php artisan migration:make create_users_table --table=users --create

And then I updated the schema for my desired fields, and ran this command:

然后我更新了我想要的字段的架构,并运行了这个命令:

php artisan migration

And it works and created the table with all of its field.

它工作并创建了包含所有字段的表。

Then I again typed the following command to create a new table's schema for comments table"

然后我再次输入以下命令为评论表创建一个新表的模式”

php artisan migration:make create_comments_table --table=comments --create

And it worked.

它奏效了。

And I updated the actual schema of the table, but then when I commanded php artisan migrate it throws an error:

我更新了表的实际架构,但是当我命令 php artisan migrate 时,它​​抛出了一个错误:

Base table or view already exists. table 'users' ....

Why? because I'm creating the comments table, what it has to do with users table.

为什么?因为我正在创建评论表,它与用户表有什么关系。

回答by arcsum

To avoid problems, try creating the tables like these

为避免出现问题,请尝试创建这样的表

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

php artisan migrate:make create_comments_table --table=comments --create=comments

taking note of the arguments in --createfor each cli command.

记下--create每个 cli 命令的参数。

回答by JohnTaa

php artisan migrate:make create_comments_table --table=comments --create

php artisan migrate:make create_comments_table --table=comments --create

The --table and --create options may also be used to indicate the name of the table, and whether the migration will be creating a new table

--table 和 --create 选项也可用于指示表的名称,以及迁移是否将创建新表

migrations

迁移