1
0

20260428120010_create_ip_enrichment.php 818 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. declare(strict_types=1);
  3. use App\Infrastructure\Db\Migrations\BaseMigration;
  4. final class CreateIpEnrichment extends BaseMigration
  5. {
  6. public function change(): void
  7. {
  8. $table = $this->table('ip_enrichment', [
  9. 'id' => false,
  10. 'primary_key' => ['ip_bin'],
  11. ]);
  12. $this->addIpBinaryColumn($table, 'ip_bin', ['null' => false]);
  13. $table
  14. ->addColumn('country_code', 'string', ['limit' => 2, 'null' => true])
  15. ->addColumn('asn', 'integer', ['null' => true, 'signed' => false])
  16. ->addColumn('as_org', 'string', ['limit' => 255, 'null' => true]);
  17. $this->addTimestampColumn($table, 'enriched_at');
  18. $table
  19. ->addIndex(['country_code'])
  20. ->addIndex(['asn'])
  21. ->create();
  22. }
  23. }