<?php

use yii\db\Migration;

class m260430_000003_add_program_fields_to_plans extends Migration
{
    public function safeUp(): void
    {
        $this->addColumn('{{%plans}}', 'who_it_for',  $this->string(255)->null()->after('description')->comment('Short line: who this program is for'));
        $this->addColumn('{{%plans}}', 'features',    $this->text()->null()->after('who_it_for')->comment('Newline-separated feature bullets'));
        $this->addColumn('{{%plans}}', 'icon',        $this->string(60)->null()->defaultValue('bi-leaf')->after('features')->comment('Bootstrap icon name'));
        $this->addColumn('{{%plans}}', 'sort_order',  $this->tinyInteger()->unsigned()->notNull()->defaultValue(0)->after('icon')->comment('Display order'));

        // Seed realistic program content for any existing plans
        // (safe to run even on empty table)
        $this->update('{{%plans}}', [
            'who_it_for' => 'Athletes, competitive players & active individuals',
            'features'   => "Performance-focused meal planning\nPre/post training nutrition\nSupplement guidance\nWeekly progress check-ins\nRecovery nutrition strategies",
            'icon'       => 'bi-trophy',
            'sort_order' => 1,
        ], ['plan_type' => 'subscription', 'sort_order' => 0]);
    }

    public function safeDown(): void
    {
        $this->dropColumn('{{%plans}}', 'sort_order');
        $this->dropColumn('{{%plans}}', 'icon');
        $this->dropColumn('{{%plans}}', 'features');
        $this->dropColumn('{{%plans}}', 'who_it_for');
    }
}
