You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.1KB

  1. <?php
  2. declare(strict_types=1);
  3. use Migrations\BaseMigration;
  4. class CreateAddresses extends BaseMigration
  5. {
  6. /**
  7. * Change Method.
  8. *
  9. * More information on this method is available here:
  10. * https://book.cakephp.org/migrations/5/guides/writing-migrations/migration-methods.html#the-change-method
  11. *
  12. * @return void
  13. */
  14. public function change(): void
  15. {
  16. $table = $this->table('addresses');
  17. $table->addColumn('territory_id', 'integer', [
  18. 'default' => null,
  19. 'limit' => 11,
  20. 'null' => false,
  21. ]);
  22. $table->addColumn('osm_type', 'string', [
  23. 'default' => null,
  24. 'limit' => 255,
  25. 'null' => false,
  26. ]);
  27. $table->addColumn('osm_id', 'biginteger', [
  28. 'default' => null,
  29. 'limit' => 20,
  30. 'null' => false,
  31. ]);
  32. $table->addColumn('house_number', 'string', [
  33. 'default' => null,
  34. 'limit' => 255,
  35. 'null' => true,
  36. ]);
  37. $table->addColumn('street', 'string', [
  38. 'default' => null,
  39. 'limit' => 255,
  40. 'null' => true,
  41. ]);
  42. $table->addColumn('full_address', 'string', [
  43. 'default' => null,
  44. 'limit' => 255,
  45. 'null' => false,
  46. ]);
  47. $table->addColumn('lat', 'decimal', [
  48. 'default' => null,
  49. 'null' => false,
  50. 'precision' => 10,
  51. 'scale' => 7,
  52. ]);
  53. $table->addColumn('lng', 'decimal', [
  54. 'default' => null,
  55. 'null' => false,
  56. 'precision' => 10,
  57. 'scale' => 7,
  58. ]);
  59. $table->addColumn('created', 'datetime', [
  60. 'default' => null,
  61. 'null' => false,
  62. ]);
  63. $table->addIndex(['territory_id']);
  64. $table->addIndex(['territory_id', 'osm_type', 'osm_id'], ['unique' => true, 'name' => 'idx_territory_osm_unique']);
  65. $table->addForeignKey('territory_id', 'territories', 'id', ['delete' => 'CASCADE', 'update' => 'NO_ACTION']);
  66. $table->create();
  67. }
  68. }

Powered by TurnKey Linux.