如何在Laravel中使用迁移?

时间:2016-02-18 04:55:50

标签: laravel laravel-5.2 laravel-migrations

我目前beginner of laravel。我正在从laravel 5.2学习official docs。在laravel学习migration之后,我非常清楚它的迁移概念。但是通过脚本代码练习,我遇到了一个问题。问题在于laravel告诉laravel allows a team to easily modify and share the application's database schema。但是,如果通过表的迁移文件创建后change the structure of database table如何8th step of the solution。我找到了解决方案here。但我怀疑Table is already exists如果我将运行该命令,那么将执行所有迁移填充。所以这会给我2013_05_23_202930_update_users.php的错误。我对么?如果是,那么请使用该链接中的示例进行说明。我想我必须只运行最后一次迁移文件mysqli_connect()。如果这是答案,那么还要键入命令来运行特定的单个迁移文件。如果有人知道答案,我们将不胜感激。

2 个答案:

答案 0 :(得分:2)

创建表格:

#3. Get device descriptions of all devices currently connected
$FT_LIST_ALL = '0x20000000'
$FT_OPEN_BY_SERIAL_NUMBER = 1
$FT_OPEN_BY_DESCRIPTION = 2
$numDevs = 0
$TotalnumDevs = 2

[Byte[][]]$BufferPtrs = (,([Byte[]] (,"" * 64)))*$TotalnumDevs
[Byte[][]]$BufferPtrs += ,""

$run=@'
[DllImport("FTD2XX.dll")] static public extern UInt32 FT_ListDevices(Array BufferPtrs, ref UInt32 pvArg2, UInt32 dwFlags);
'@
$typef = Add-Type -MemberDefinition $run -Name "ListDevices1" -PassThru
$ftStatus = $typef::FT_ListDevices($BufferPtrs, [ref] $numDevs, $FT_LIST_ALL -bor $FT_OPEN_BY_DESCRIPTION)
'(FT_OK = 0) ftStatus = ' + [string]$ftStatus
'Number of Devices = ' + [string]$numDevs
[ref] $BufferPtrs    #Display the Pointers Array
$BufferPtrs.GetType()

要向此表添加一些列:

  

php artisan make:migration add_somthing_to_users_table --table = users

if (!Schema::hasTable('users')) {
        Schema::create('users', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->increments('id')->unsigned();
            $table->string('username'); 
            $table->string('password', 60);                
            $table->timestamps();
            $table->softDeletes();
        });
    }

答案 1 :(得分:0)

哦,伙计们,我找到了解决方案。在引用this link之后,我发现问题的发布链接中的解决方案是正确的。由于某些我不知道的原因,表格没有改变。但重启我的系统后,它的工作原理。但@rome的回答也是可以接受的。

相关问题