I am working on laravel 4.1. I have a ready made mysql database created by other means. I have managed to create a migration from the existing database that would create all the tables in the database if run.
I want the migration to also include the stored procedures, functions and events present in the database.
I would specifically like to know how to create laravel migrations for stored procedures, events and functions from an existing database.
To execute raw SQL commands in a migration (like the creation of a stored procedure) you can do:
public function up()
{
DB::unprepared('CREATE PROCEDURE my_procedure( IN param INT(10) ) BEGIN /* here your SP code */ END');
}
public function down()
{
DB::unprepared('DROP PROCEDURE IF EXISTS my_procedure');
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With