小编Jho*_*des的帖子

Laravel 迁移无法创建外键

我正在尝试创建一个外键,artisan 没有显示任何错误,只是没有创建我的外键,这可能是我的代码:

1°表:

Schema::create('cooperados', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->timestamps();
        $table->string('nameCoop', 255);
        $table->integer('numCoop');
        $table->string('cpfCoop', 11);
        $table->date('dtCad');
        $table->date('dtDem')->nullable();
        $table->text('description')->nullable();
        $table->decimal('subscritas', 6, 2);
        $table->decimal('integralizadas', 6,2)->nullable();
        $table->decimal('aintegralizar', 6,2)->nullable();
        $table->enum('status', ['ativo','inativo'])->default('ativo');
    });
Run Code Online (Sandbox Code Playgroud)

外键表

public function up()
    {
        Schema::create('mov', function (Blueprint $table) {
            $table->bigIncrements('idMov');
            $table->timestamps();
            $table->integer('id_coop')->unsigned;
            $table->foreign('id_coop')->references('id')->on('cooperados');
            $table->decimal('valor', 6, 2);
        });
    }
Run Code Online (Sandbox Code Playgroud)

php mysql sql laravel laravel-artisan

1
推荐指数
1
解决办法
1227
查看次数

标签 统计

laravel ×1

laravel-artisan ×1

mysql ×1

php ×1

sql ×1