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

/**
 * Migration 011 — Testimonials & social proof
 * source_type: brand | talent  — quote cards + optional video.
 */
class Migration_Create_testimonials extends CI_Migration {

	public function up()
	{
		$this->dbforge->add_field(array(
			'id'            => array('type' => 'INT', 'constraint' => 11, 'unsigned' => TRUE, 'auto_increment' => TRUE),
			'author_name'   => array('type' => 'VARCHAR', 'constraint' => 140),
			'author_role'   => array('type' => 'VARCHAR', 'constraint' => 160, 'null' => TRUE),
			'source_type'   => array('type' => "ENUM('brand','talent')", 'default' => 'brand'),
			'quote'         => array('type' => 'TEXT'),
			'photo'         => array('type' => 'VARCHAR', 'constraint' => 255, 'null' => TRUE),
			'rating'        => array('type' => 'TINYINT', 'constraint' => 1, 'default' => 5),
			'video_type'    => array('type' => "ENUM('none','youtube')", 'default' => 'none'),
			'youtube_id'    => array('type' => 'VARCHAR', 'constraint' => 40, 'null' => TRUE),
			'is_featured'   => array('type' => 'TINYINT', 'constraint' => 1, 'default' => 1),
			'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('testimonials', TRUE, array('ENGINE' => 'InnoDB'));

		$now = date('Y-m-d H:i:s');
		$this->db->insert_batch('testimonials', array(
			array('author_name' => 'Aurora Couture', 'author_role' => 'Fashion Brand',
				'source_type' => 'brand', 'rating' => 5,
				'quote' => 'Bloom Iris understood our vision instantly and delivered a campaign that elevated our entire brand.',
				'is_featured' => 1, 'sort_order' => 1, 'is_active' => 1, 'created_at' => $now),
			array('author_name' => 'Naa Adjeley', 'author_role' => 'Lifestyle Creator',
				'source_type' => 'talent', 'rating' => 5,
				'quote' => 'Joining the Bloom Iris network opened doors I never imagined. They truly invest in their talent.',
				'is_featured' => 1, 'sort_order' => 2, 'is_active' => 1, 'created_at' => $now),
			array('author_name' => 'Lumen Beverages', 'author_role' => 'Marketing Lead',
				'source_type' => 'brand', 'rating' => 5,
				'quote' => 'The activation they produced for us was flawless from concept to execution.',
				'is_featured' => 1, 'sort_order' => 3, 'is_active' => 1, 'created_at' => $now),
		));
	}

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