new network model and mfBaseModelV2
This commit is contained in:
34
db/migrations/20251214150000_create_journal_table.php
Normal file
34
db/migrations/20251214150000_create_journal_table.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class CreateJournalTable extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if ($this->getEnvironment() == "thetool") {
|
||||
$this->table('Journal')
|
||||
->addColumn('user_id', 'integer', ['null' => true, 'signed' => false])
|
||||
->addColumn('model', 'string', ['limit' => 255, 'null' => false])
|
||||
->addColumn('record_id', 'integer', ['null' => false])
|
||||
->addColumn('action', 'enum', ['values' => ['create', 'update', 'delete'], 'null' => false])
|
||||
->addColumn('field', 'string', ['limit' => 255, 'null' => true])
|
||||
->addColumn('old_value', 'text', ['null' => true])
|
||||
->addColumn('new_value', 'text', ['null' => true])
|
||||
->addColumn('timestamp', 'timestamp', ['default' => 'CURRENT_TIMESTAMP'])
|
||||
->addIndex(['model', 'record_id'], ['name' => 'idx_model_record'])
|
||||
->addIndex(['user_id'], ['name' => 'idx_user'])
|
||||
->addIndex(['action'], ['name' => 'idx_action'])
|
||||
->addIndex(['timestamp'], ['name' => 'idx_timestamp'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if ($this->getEnvironment() == "thetool") {
|
||||
$this->table('Journal')->drop()->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user