58 lines
1.5 KiB
PHP
58 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class CreateAdminNotificationSubjects extends Migration
|
|
{
|
|
public function up()
|
|
{
|
|
if ($this->db->tableExists('admin_notification_subjects')) {
|
|
return;
|
|
}
|
|
|
|
$this->forge->addField([
|
|
'id' => [
|
|
'type' => 'INT',
|
|
'constraint' => 11,
|
|
'unsigned' => true,
|
|
'auto_increment' => true,
|
|
],
|
|
'admin_id' => [
|
|
'type' => 'INT',
|
|
'constraint' => 11,
|
|
'unsigned' => true,
|
|
'null' => false,
|
|
],
|
|
'subject' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 100,
|
|
'null' => false,
|
|
],
|
|
'created_at' => [
|
|
'type' => 'DATETIME',
|
|
'null' => true,
|
|
],
|
|
'updated_at' => [
|
|
'type' => 'DATETIME',
|
|
'null' => true,
|
|
],
|
|
]);
|
|
|
|
$this->forge->addKey('id', true);
|
|
$this->forge->addKey('admin_id');
|
|
$this->forge->addUniqueKey(['admin_id', 'subject']);
|
|
$this->forge->createTable('admin_notification_subjects', true);
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
if (!$this->db->tableExists('admin_notification_subjects')) {
|
|
return;
|
|
}
|
|
|
|
$this->forge->dropTable('admin_notification_subjects', true);
|
|
}
|
|
}
|