Foreign Key between different databases

5

Is it possible to link between two different databases in one Migration? I'm using Postgres.

What I have:

$table->integer('id_cliente_produto')->unsigned();
$table->foreign('id_cliente_produto')->references('id_cliente_produto')->on('clienteproduto');

I need something like:

$table->integer('id_cliente_produto')->unsigned();
$table>foreign('id_cliente_produto')>references('id_cliente_produto')->on('Banco2.tabela');
    
asked by anonymous 27.06.2016 / 20:10

1 answer

0

I never needed to do this, but giving a google search I found this solution (I did not test to see if it works):

$table>foreign('id_cliente_produto')>references('id_cliente_produto')->on(new Illuminate\Database\Query\Expression('Banco2.tabela'));

Recommendation: Put the reference to the bank name in some configuration file, in case the name of the bank changes, you only have to change one file.

    
23.01.2017 / 00:05