【发布时间】:2017-06-29 15:44:12
【问题描述】:
我有两个数据库,每个里面都有一个表:
database_one -> one (table)
database_two -> two (table)
我想在 database_two 中的两个表之间创建多对多关系;但这些表位于两个不同的数据库中。
这是我在同一个数据库上创建数据透视表的代码:
Schema::connection('database_two')->create('one_two', function (Blueprint $table) {
$table->integer('one_id')->unsigned()->nullable();
$table->foreign('one_id')->references('id')
->on('one')->onDelete('cascade');
$table->integer('two_id')->unsigned()->nullable();
$table->foreign('two_id')->references('id')
->on('two')->onDelete('cascade');
$table->timestamps();
});
我该怎么办?
谢谢!
【问题讨论】:
标签: php mysql database laravel blueprint