使用迁移更改表 Laravel 5

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33900450/
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-08 17:10:11  来源:igfitidea点击:

Alter table Laravel 5 with migration

laravelmigration

提问by Sandy Raymond Rodrguez Mendoza

I'm making a application with laravel 5. I change the field 'vote ' that I have defined as

我正在使用 laravel 5 制作应用程序。我更改了我定义为的字段“投票”

$ table-> enum ('vote', [ '- 1 ', '0 ', '1 ']); 

and should be as follows

并且应该如下

$ table-> enum ('vote', [' 1', ' 2', ' 3', ' 4', ' 5'] ) ;

回答by davejal

To do this you should follow these steps:

为此,您应该按照以下步骤操作:

  1. create a new migration file

    php artisan make:migration update_votes_table
    
  2. open the newly created migration file (app_folder\database\migrations{date_migrationfile_was_created}-update_votes_tables.php)

  3. change the columns you want to change

  1. 创建一个新的迁移文件

    php artisan make:migration update_votes_table
    
  2. 打开新创建的迁移文件(app_folder\database\migrations{date_migrationfile_was_created}-update_votes_tables.php)

  3. 更改要更改的列

For more details see the documentation on database migrations

有关更多详细信息,请参阅有关数据库迁移文档

Note:If you add your migrations file to the question we could provide more detailed help

注意:如果您将迁移文件添加到问题中,我们可以提供更详细的帮助

回答by Moode Osman

this how i do it:

这就是我的做法:

 php artisan make:migration Alter_votes_to_tableName --table=tableName

open the file and change it then

打开文件并更改它然后

php artisan migrate

回答by Rohit Saini

first of all create new migration using below command

首先使用以下命令创建新的迁移

php artisan make:migration Alter_your_comment_yourTableName --table=yourTableName

change the file as per your requirements and after that run the below command in composer

根据您的要求更改文件,然后在 Composer 中运行以下命令

php artisan migrate