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

/**
 * Migration 012 — Team & founders
 * is_founder distinguishes founders for the About page editorial layout.
 */
class Migration_Create_team 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),
			'role'       => array('type' => 'VARCHAR', 'constraint' => 160),
			'bio'        => array('type' => 'TEXT', 'null' => TRUE),
			'photo'      => array('type' => 'VARCHAR', 'constraint' => 255, 'null' => TRUE),
			'instagram'  => array('type' => 'VARCHAR', 'constraint' => 200, 'null' => TRUE),
			'linkedin'   => array('type' => 'VARCHAR', 'constraint' => 200, 'null' => TRUE),
			'is_founder' => array('type' => 'TINYINT', 'constraint' => 1, 'default' => 0),
			'sort_order' => array('type' => 'INT', 'constraint' => 5, 'default' => 0),
			'is_active'  => array('type' => 'TINYINT', 'constraint' => 1, 'default' => 1),
			'created_at' => array('type' => 'DATETIME', 'null' => TRUE),
			'updated_at' => array('type' => 'DATETIME', 'null' => TRUE),
		));
		$this->dbforge->add_key('id', TRUE);
		$this->dbforge->create_table('team', TRUE, array('ENGINE' => 'InnoDB'));

		$now = date('Y-m-d H:i:s');
		$this->db->insert_batch('team', array(
			array('name' => 'Founder Name', 'role' => 'Founder & Creative Director',
				'bio' => 'The creative force behind Bloom Iris Agency.',
				'is_founder' => 1, 'sort_order' => 1, 'is_active' => 1, 'created_at' => $now),
			array('name' => 'Team Member', 'role' => 'Head of Talent',
				'bio' => 'Leads talent discovery and representation.',
				'is_founder' => 0, 'sort_order' => 2, 'is_active' => 1, 'created_at' => $now),
		));
	}

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