<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddCpElementsToLearningDevices extends Migration
{
    public function up()
    {
        if ($this->db->fieldExists('cp_elements', 'learning_devices')) return;
        $this->forge->addColumn('learning_devices', [
            'cp_elements' => [
                'type' => 'JSON',
                'null' => true,
                'default' => null,
                'after' => 'cp_content'
            ]
        ]);
    }

    public function down()
    {
        $this->forge->dropColumn('learning_devices', 'cp_elements');
    }
}
