Initial commit BIJ CI4
This commit is contained in:
0
app/Database/Migrations/.gitkeep
Normal file
0
app/Database/Migrations/.gitkeep
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class CreateAdminActivityLogs extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$this->forge->addField([
|
||||
'id' => [
|
||||
'type' => 'BIGINT',
|
||||
'unsigned' => true,
|
||||
'auto_increment' => true,
|
||||
],
|
||||
'admin_user' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 191,
|
||||
'default' => '',
|
||||
],
|
||||
'action' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 128,
|
||||
'default' => '',
|
||||
],
|
||||
'endpoint' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 512,
|
||||
'default' => '',
|
||||
],
|
||||
'payload' => [
|
||||
'type' => 'TEXT',
|
||||
'null' => true,
|
||||
],
|
||||
'ip_address' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 45,
|
||||
'default' => '',
|
||||
],
|
||||
'user_agent' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 512,
|
||||
'default' => '',
|
||||
],
|
||||
'auth_source' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 32,
|
||||
'null' => true,
|
||||
],
|
||||
'roles_json' => [
|
||||
'type' => 'TEXT',
|
||||
'null' => true,
|
||||
],
|
||||
'outcome' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 32,
|
||||
'default' => 'success',
|
||||
],
|
||||
'created_at' => [
|
||||
'type' => 'DATETIME',
|
||||
'null' => false,
|
||||
],
|
||||
]);
|
||||
|
||||
$this->forge->addKey('id', true);
|
||||
$this->forge->addKey('created_at');
|
||||
$this->forge->addKey(['action', 'created_at']);
|
||||
$this->forge->createTable('admin_activity_logs', true, [
|
||||
'ENGINE' => 'InnoDB',
|
||||
]);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
$this->forge->dropTable('admin_activity_logs', true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddIdPegawaiToAdminUsers extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (! $this->db->tableExists('admin_users')) {
|
||||
return;
|
||||
}
|
||||
if ($this->db->fieldExists('id_pegawai', 'admin_users')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->forge->addColumn('admin_users', [
|
||||
'id_pegawai' => [
|
||||
'type' => 'INT',
|
||||
'constraint' => 11,
|
||||
'unsigned' => true,
|
||||
'null' => true,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if (! $this->db->tableExists('admin_users')) {
|
||||
return;
|
||||
}
|
||||
if (! $this->db->fieldExists('id_pegawai', 'admin_users')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->forge->dropColumn('admin_users', 'id_pegawai');
|
||||
}
|
||||
}
|
||||
0
app/Database/Seeds/.gitkeep
Normal file
0
app/Database/Seeds/.gitkeep
Normal file
Reference in New Issue
Block a user