簡體   English   中英

Laravel遷移在表中分配2個主鍵

[英]Laravel migration assigns 2 primary key in a table

我在laravel遷移中遇到問題,我在laravel遷移文件中有tqo interger,當我嘗試遷移時,它向我報告錯誤,指出該遷移包含2個主鍵。 有沒有人對此有任何想法。 幫助將不勝感激。

<?php    
    use Illuminate\Database\Schema\Blueprint;
    use Illuminate\Database\Migrations\Migration;    
    class CreateLoginTable extends Migration {    
        /**
         * Run the migrations.
         *
         * @return void
         */
        public function up(){
            Schema::create('login', function(Blueprint $table)
            {
                $table->engine ='InnoDB';
                $table->increments('id');
                $table->string ('email', 255);
                $table->string ('username', 255);
                $table->string ('password', 255);
                $table->string ('password_temp', 255);
                $table->string ('code', 255);
                $table->integer ('active', 11);
                $table->timestamps();               
            });
        }    
        /**
         * Reverse the migrations.
         *
         * @return void
         */
        public function down()
        {
            Schema::drop('login');
        }    
    }

整數列的調用沒有長度(與純mysql中不同)。 所以就這樣稱呼它:

$table->integer ('active');

它會工作。 文件: http//laravel.com/docs/4.2/schema#adding-columns

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM