<?php
declare(strict_types=1);

use Migrations\BaseMigration;

class SeedPageContentData extends BaseMigration
{
    public function up(): void
    {
        $now = date('Y-m-d H:i:s');

        $row = $this->fetchRow('SELECT COUNT(*) AS count FROM offerings');
        if ($row === false || (int)$row['count'] === 0) {
            $this->execute("
                INSERT INTO offerings (title, headline, summary, sort_order, created, modified) VALUES
                ('Pottery', 'Hands-on pottery tuition for learners who want to build confidence with clay.', 'Explore foundational wheel and hand-building techniques in a calm, supportive environment that leaves room for questions and steady progress.', 1, '{$now}', '{$now}'),
                ('Knitting', 'Practical knitting guidance for beginners and returning makers.', 'Build skill at a comfortable pace with clear instruction, patient support, and enough flexibility to meet you where you are.', 2, '{$now}', '{$now}')
            ");
        }

        $row = $this->fetchRow('SELECT COUNT(*) AS count FROM benefits');
        if ($row === false || (int)$row['count'] === 0) {
            $this->execute("
                INSERT INTO benefits (title, summary, sort_order, created, modified) VALUES
                ('Patient, personal teaching', 'Lessons are designed to feel welcoming and manageable, especially for people taking their first step into pottery or knitting.', 1, '{$now}', '{$now}'),
                ('Room to begin gently', 'You can ask questions about class fit, pace, and experience level before deciding what feels right for you.', 2, '{$now}', '{$now}'),
                ('Guidance that meets you where you are', 'Whether you are brand new or returning after time away, the goal is to help you choose a comfortable, realistic next step.', 3, '{$now}', '{$now}')
            ");
        }

        $row = $this->fetchRow('SELECT COUNT(*) AS count FROM journey_steps');
        if ($row === false || (int)$row['count'] === 0) {
            $this->execute("
                INSERT INTO journey_steps (title, summary, sort_order, created, modified) VALUES
                ('Tell us what you are interested in', 'Let us know whether you are drawn to pottery, knitting, or still deciding where to begin.', 1, '{$now}', '{$now}'),
                ('Share your questions', 'Ask about confidence level, class fit, pace, materials, or anything else that would help you feel ready to begin.', 2, '{$now}', '{$now}'),
                ('Receive a clear reply', 'The team will read your enquiry carefully and come back with the next step that makes the most sense for you.', 3, '{$now}', '{$now}')
            ");
        }
    }

    public function down(): void
    {
        $this->execute('DELETE FROM offerings');
        $this->execute('DELETE FROM benefits');
        $this->execute('DELETE FROM journey_steps');
    }
}
