模式构建器 - 如何在创建表后执行查询Laravel 5

时间:2015-07-23 13:28:28

标签: php sql postgresql laravel laravel-5

我有下一次数据库迁移:

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class Ift extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        DB::transaction(function(){
            Schema::create('displaio.ift', function($table){
                $table->increments('id');
                $table->integer('user_id');
                $table->string('address_line1');
                ...
                $table->string('tax_id');
                $table->timestamps();
                $table->softDeletes();
            });

            \DB::connection('old-displate')->insert('INSERT INTO displaio.ift (user_id, address_line1, address_line2, address_city, address_state, address_zip, country, first_name, last_name, birthday, tax_id) (SELECT id, address_line1, address_line2, address_city, address_state, address_zip, ift_country, ift_first_name, ift_last_name, ift_birthday, ift_tax_id FROM displaio.user WHERE ift_first_name <> \'\' AND ift_last_name <> \'\' AND address_line1 <> \'\' AND address_line2 <> \'\' AND address_city <> \'\' AND address_state <> \'\' AND address_zip <> \'\' AND ift_tax_id <> \'\')');
        });
    }
    ...
}

当我运行php artisan migrate控制台时,请告诉我:[PDOException] SQLSTATE[42P01]: Undefined table: 7。在relation displaio.ift is undefined旁边写下INSERT INTO displaio.ift。如何在Schema :: create()之后执行此查询?有可能吗?

0 个答案:

没有答案