<?php

use yii\db\Migration;

class m260430_000001_create_testimonials_table extends Migration
{
    public function safeUp(): void
    {
        $this->createTable('{{%testimonials}}', [
            'id'           => $this->primaryKey()->unsigned(),
            'name'         => $this->string(120)->notNull(),
            'role'         => $this->string(120)->notNull()->defaultValue(''),
            'quote'        => $this->text()->notNull(),
            'avatar_letter'=> $this->char(1)->notNull()->defaultValue('A'),
            'sort_order'   => $this->smallInteger()->unsigned()->notNull()->defaultValue(0),
            'is_active'    => $this->tinyInteger(1)->unsigned()->notNull()->defaultValue(1),
            'created_at'   => $this->integer()->unsigned()->notNull(),
            'updated_at'   => $this->integer()->unsigned()->notNull(),
        ], 'ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci');

        // Seed default testimonials
        $now = time();
        $this->batchInsert('{{%testimonials}}',
            ['name', 'role', 'quote', 'avatar_letter', 'sort_order', 'is_active', 'created_at', 'updated_at'],
            [
                ['Priya M.',  'Weight Loss Client',      'Lost 12 kg in 4 months without starving! The plan was so realistic and the WhatsApp support kept me going on tough days.',           'P', 1, 1, $now, $now],
                ['Anjali R.', 'Medical Nutrition Client', 'My PCOS symptoms improved significantly after 3 months. My doctor was genuinely impressed by my blood reports!',                    'A', 2, 1, $now, $now],
                ['Rahul K.',  'Sports Nutrition Client',  'As a marathon runner, I needed performance nutrition. My race times improved by 8 minutes after following the sports plan!',         'R', 3, 1, $now, $now],
            ]
        );
    }

    public function safeDown(): void
    {
        $this->dropTable('{{%testimonials}}');
    }
}
