65 lines
1.7 KiB
PHP
65 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class CreateSubjectCurriculumItems extends Migration
|
|
{
|
|
public function up()
|
|
{
|
|
if ($this->db->tableExists('subject_curriculum_items')) {
|
|
return;
|
|
}
|
|
|
|
$this->forge->addField([
|
|
'id' => [
|
|
'type' => 'INT',
|
|
'constraint' => 11,
|
|
'unsigned' => true,
|
|
'auto_increment' => true,
|
|
],
|
|
'class_id' => [
|
|
'type' => 'INT',
|
|
'constraint' => 11,
|
|
'unsigned' => true,
|
|
],
|
|
'subject' => [
|
|
'type' => 'ENUM',
|
|
'constraint' => ['islamic', 'quran'],
|
|
'default' => 'islamic',
|
|
],
|
|
'unit_number' => [
|
|
'type' => 'SMALLINT',
|
|
'null' => true,
|
|
],
|
|
'unit_title' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 255,
|
|
'null' => true,
|
|
],
|
|
'chapter_name' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 255,
|
|
],
|
|
'created_at' => [
|
|
'type' => 'DATETIME',
|
|
'null' => true,
|
|
],
|
|
'updated_at' => [
|
|
'type' => 'DATETIME',
|
|
'null' => true,
|
|
],
|
|
]);
|
|
|
|
$this->forge->addKey('id', true);
|
|
$this->forge->addKey(['class_id', 'subject']);
|
|
$this->forge->createTable('subject_curriculum_items');
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
$this->forge->dropTable('subject_curriculum_items', true);
|
|
}
|
|
}
|