<?php

class m150403_113610_create_plate_auth_insert_profile_auth_triggers extends MyDbMigration
{
  public function up()
  {
  	return;
  	
    $this->createTrigger(
        'plate_auth_insert_profile_auth_trigger_insert',
        'plate_auth_insert_profile',
        'AFTER',
        'INSERT',
        "INSERT INTO authitem 
        (name, type, description, bizrule, data)
        VALUES
        (CONCAT('plate_auth_insert_profile_',NEW.id),0,CONCAT('Prof. ins. perm. ',NEW.name,'(',NEW.id,')'), '', 'N;')"
    );
    $this->createTrigger(
        'plate_auth_insert_profile_auth_trigger_delete',
        'plate_auth_insert_profile',
        'AFTER',
        'DELETE',
        "DELETE FROM authitem WHERE name=CONCAT('plate_auth_insert_profile_',OLD.id)"
    );
  }

  public function down()
  {
    $this->dropTrigger('plate_auth_insert_profile_auth_trigger_delete');
    $this->dropTrigger('plate_auth_insert_profile_auth_trigger_insert');
    return true;
  }
}
