Problem:
I have a client whose application works with two separate databases. One of the functions within the application copies data from database 1, to database 2 in a different format. Additionally, when inserting into database 2, a trigger is called on database 2 to pull a pre-generated "identifier" and save that along with the entry into database 2 row. Whew.
Well, it works in production and dev, but I need to know how to be able to test this piece, as the client controls both databases...ideally, I'd like to create a migration that creates the trigger, so that when I perform my phpunit tests, I can replicate the same intended behavior.
How?
Within the migration, you have to specify the connection, then call the "unprepared" function.
Example:
public function up()
{
DB::connection('whateverYourSecondDatabaseConnectionIs')->unprepared("
create trigger GetIDFromOtherTable
BLAH BLAH BLAH TRIGGER INFO
;");
}
public function down()
{
\Illuminate\Support\Facades\DB::connection('whateverYourSecondDatabaseConnectionIs')->unprepared("
DROP trigger if EXISTS GetIDFromOtherTable;");
}