jeudi 5 novembre 2015

Add triggers to table using migrations - Laravel 5.1

I've seen a few answers to this question but none of them work, and none of them were for 5.1

This is my migration:

public function up()
    {
        DB::unprepared('
            USE `widatdb`;
            DELIMITER $$
            CREATE TRIGGER `topics_AUPD` BEFORE UPDATE ON `topics` FOR EACH ROW
            BEGIN
                IF (NEW.abstract <> OLD.abstract)
                THEN
                    SET NEW.got_updated = 1;
                END IF;
            END
        ');
    }

If I introduce a syntax error in the trigger declaration, its error will be shown during migration. But right now, after running php artisan migrate ( which gets finished without any errors ), the trigger is not added to the table. Any idea?

Thanks :-)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire