<?php

use Phalcon\Mvc\Model\Migration;

class NotificationsMigration_296 extends Migration
{
    public function up()
    {
        $this->down(); 

        self::$connection->execute("
            ALTER TABLE jaga.notifications
            ADD CONSTRAINT notifications_tenant_id_owner_user_id_fkey FOREIGN KEY (owner_user_id)
            REFERENCES jaga.um_user (um_id) MATCH SIMPLE
            ON UPDATE NO ACTION
            ON DELETE NO ACTION;

            ALTER TABLE jaga.notifications
            ADD CONSTRAINT notifications_tenant_id_sender_user_id_fkey FOREIGN KEY (sender_user_id)
            REFERENCES jaga.um_user (um_id) MATCH SIMPLE
            ON UPDATE NO ACTION
            ON DELETE NO ACTION;
        ");
    }

    public function down()
    {
        self::$connection->execute("
            ALTER TABLE jaga.notifications DROP CONSTRAINT IF EXISTS notifications_tenant_id_owner_user_id_fkey;

            ALTER TABLE jaga.notifications DROP CONSTRAINT IF EXISTS notifications_tenant_id_sender_user_id_fkey;
        ");
    }
}
