<?php

defined('BASEPATH') OR exit('No direct script access allowed');
include_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'MY_Migration.php';

class Migration_Add_user_doorprize extends MY_Migration {

    public function up() {
        $this->dbforge->add_field([
            'doorprize_id' => static::foreign(),
            'user_id' => static::foreign(),
            'status' => static::status('1 = ACTIVE, 2 = VOTED'),
            'CONSTRAINT ' . $this->db->dbprefix . 'user_doorprize_doorprize FOREIGN KEY (doorprize_id) REFERENCES ' . $this->db->dbprefix . 'doorprize(id) ON UPDATE CASCADE ON DELETE CASCADE',
            'CONSTRAINT ' . $this->db->dbprefix . 'user_doorprize_user FOREIGN KEY (user_id) REFERENCES ' . $this->db->dbprefix . 'users(id) ON UPDATE CASCADE ON DELETE CASCADE'
            ] + static::default());
        $this->dbforge->create_table('user_doorprize');
    }

    //--------------------------------------------------------------------

    public function down() {
        $this->dbforge->drop_table('user_doorprize');
    }

}
