<?php
defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * Migration 008 — Talent network applications
 * Workflow status: pending -> shortlisted -> approved / rejected
 */
class Migration_Create_applications extends CI_Migration {

	public function up()
	{
		$this->dbforge->add_field(array(
			'id'            => array('type' => 'INT', 'constraint' => 11, 'unsigned' => TRUE, 'auto_increment' => TRUE),
			'name'          => array('type' => 'VARCHAR', 'constraint' => 140),
			'email'         => array('type' => 'VARCHAR', 'constraint' => 160),
			'phone'         => array('type' => 'VARCHAR', 'constraint' => 30, 'null' => TRUE),
			'category'      => array('type' => 'VARCHAR', 'constraint' => 60),
			'location'      => array('type' => 'VARCHAR', 'constraint' => 120, 'null' => TRUE),
			'instagram'     => array('type' => 'VARCHAR', 'constraint' => 160, 'null' => TRUE),
			'followers'     => array('type' => 'VARCHAR', 'constraint' => 60, 'null' => TRUE),
			'portfolio_url' => array('type' => 'VARCHAR', 'constraint' => 255, 'null' => TRUE),
			'bio'           => array('type' => 'TEXT', 'null' => TRUE),
			'photo'         => array('type' => 'VARCHAR', 'constraint' => 255, 'null' => TRUE),
			'status'        => array('type' => "ENUM('pending','shortlisted','approved','rejected')", 'default' => 'pending'),
			'admin_notes'   => array('type' => 'TEXT', 'null' => TRUE),
			'ip_address'    => array('type' => 'VARCHAR', 'constraint' => 45, 'null' => TRUE),
			'created_at'    => array('type' => 'DATETIME', 'null' => TRUE),
			'updated_at'    => array('type' => 'DATETIME', 'null' => TRUE),
		));
		$this->dbforge->add_key('id', TRUE);
		$this->dbforge->add_key('status');
		$this->dbforge->create_table('applications', TRUE, array('ENGINE' => 'InnoDB'));
	}

	public function down()
	{
		$this->dbforge->drop_table('applications', TRUE);
	}
}
