20260428120005_create_reporters.php 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. declare(strict_types=1);
  3. use App\Infrastructure\Db\Migrations\BaseMigration;
  4. final class CreateReporters extends BaseMigration
  5. {
  6. public function change(): void
  7. {
  8. $table = $this->table('reporters');
  9. $table
  10. ->addColumn('name', 'string', ['limit' => 128, 'null' => false])
  11. ->addColumn('description', 'text', ['null' => true])
  12. ->addColumn('trust_weight', 'decimal', ['precision' => 5, 'scale' => 2, 'null' => false, 'default' => '1.00'])
  13. ->addColumn('is_active', 'boolean', ['null' => false, 'default' => true])
  14. ->addColumn('created_by_user_id', 'integer', ['null' => true, 'signed' => false]);
  15. $this->addTimestampColumn($table, 'created_at');
  16. $table
  17. ->addIndex(['name'], ['unique' => true, 'name' => 'uniq_reporters_name'])
  18. ->addIndex(['created_by_user_id'])
  19. ->addForeignKey(
  20. 'created_by_user_id',
  21. 'users',
  22. 'id',
  23. ['delete' => 'SET_NULL', 'update' => 'NO_ACTION', 'constraint' => 'fk_reporters_created_by']
  24. )
  25. ->create();
  26. }
  27. }