Solved now, there was issues with class naming,
I delete the migration file and generate new one
php artisan generate:migration create_trigger
After it was generated I copy and paste the same code and it works just fine, some time when you work late, you pay a good price.
Here is the final working code for creating trigger through migration.
it works both with RAW and UNPREPARED method.
<?php
use Illuminate\Database\Migrations\Migration;
class CreateTrigger extends Migration {
public function up()
{
DB::unprepared('
CREATE TRIGGER tr_User_Default_Member_Role AFTER INSERT ON `users` FOR EACH ROW
BEGIN
INSERT INTO role_user (`role_id`, `user_id`, `created_at`, `updated_at`) VALUES (3, NEW.id, now(), null);
END
');
}
public function down()
{
DB::unprepared('DROP TRIGGER `tr_User_Default_Member_Role`');
}
}