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

/**
 * Migration 015 — Editable static pages (About, etc.)
 * blocks stored as JSON to allow flexible, structured page content.
 */
class Migration_Create_pages extends CI_Migration {

	public function up()
	{
		$this->dbforge->add_field(array(
			'id'         => array('type' => 'INT', 'constraint' => 11, 'unsigned' => TRUE, 'auto_increment' => TRUE),
			'slug'       => array('type' => 'VARCHAR', 'constraint' => 120),
			'title'      => array('type' => 'VARCHAR', 'constraint' => 200),
			'blocks'     => array('type' => 'LONGTEXT', 'null' => TRUE, 'comment' => 'JSON content blocks'),
			'hero_image' => array('type' => 'VARCHAR', 'constraint' => 255, 'null' => TRUE),
			'meta_title' => array('type' => 'VARCHAR', 'constraint' => 200, 'null' => TRUE),
			'meta_desc'  => array('type' => 'VARCHAR', 'constraint' => 300, 'null' => TRUE),
			'updated_at' => array('type' => 'DATETIME', 'null' => TRUE),
		));
		$this->dbforge->add_key('id', TRUE);
		$this->dbforge->add_key('slug');
		$this->dbforge->create_table('pages', TRUE, array('ENGINE' => 'InnoDB'));

		$now = date('Y-m-d H:i:s');
		$about_blocks = json_encode(array(
			'origin'     => 'Bloom Iris Agency was founded to give creative talent a true home and to give brands a creative partner that thinks differently. What began as a small collective has grown into a full creative agency spanning fashion, lifestyle, talent management and brand collaborations.',
			'vision'     => 'To be the definitive creative gateway for talent and brands — a place where bold ideas bloom into unforgettable work.',
			'mission'    => 'We craft campaigns, manage talent and produce experiences that move brands forward and elevate the creatives we represent.',
			'philosophy' => 'Editorial. Bold. Aspirational. Every project we touch is treated as a piece of the Bloom Iris creative universe.',
			'difference' => 'We are not a brochure agency. We are an operational creative partner — strategy, talent, production and delivery under one roof.',
			'values'     => array('Creativity without compromise', 'Talent-first representation', 'Editorial excellence', 'Genuine partnership'),
		));
		$this->db->insert('pages', array(
			'slug' => 'about', 'title' => 'About Bloom Iris',
			'blocks' => $about_blocks,
			'meta_title' => 'About — Bloom Iris Agency',
			'meta_desc' => 'The story, vision and creative philosophy behind Bloom Iris Agency.',
			'updated_at' => $now,
		));
	}

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