Blame view

console/migrations/m160712_144806_create_bus_stop.php 3.67 KB
31f7c78a   Yarik   Yarik
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
  <?php
  
      use yii\db\Migration;
  
      /**
       * Handles the creation for table `service_object`.
       */
      class m160712_144806_create_bus_stop extends Migration
      {
  
          /**
           * @inheritdoc
           */
          public function up()
          {
              $this->createTable('bus_stop', [
                  'bus_stop_id'            => $this->primaryKey()
                                                   ->comment('Індекс'),
                  'road_id'                => $this->integer()
                                                   ->comment('Дорога'),
                  'region_id'              => $this->integer()
                                                   ->comment('Область'),
                  'settlement_id'          => $this->integer()
                                                   ->comment('Назва населеного пункту'),
                  'location_right'         => $this->float()
                                                   ->comment('Місцезнаходження, км+ справа'),
                  'location_left'          => $this->float()
                                                   ->comment('Місцезнаходження, км+ зліва'),
                  'surface_type_id'        => $this->integer()
                                                   ->comment('Тип покриття'),
                  'area_stop_availability' => $this->integer()
                                                   ->comment('Наявність елементів зупин. майдан'),
                  'area_land_availability' => $this->integer()
                                                   ->comment('Наявність елементів посад. майдан'),
                  'pocket_availability'    => $this->integer()
                                                   ->comment('Наявність елементів заїзна кишеня'),
                  'toilet_availability'    => $this->integer()
                                                   ->comment('Наявність елементів туалет'),
                  'year_build'             => $this->integer()
                                                   ->comment('Рік будівництва'),
                  'year_repair'            => $this->integer()
                                                   ->comment('Рік ремонту'),
                  'state_common_id'        => $this->integer()
                                                   ->comment('Технічний стан'),
              ]);
              $this->addForeignKey('bus_stop_road', 'bus_stop', 'road_id', 'road', 'road_id', 'CASCADE', 'CASCADE');
              $this->addForeignKey('bus_stop_region', 'bus_stop', 'region_id', 'region', 'region_id', 'CASCADE', 'CASCADE');
              $this->addForeignKey('bus_stop_settlement', 'bus_stop', 'settlement_id', 'settlement', 'settlement_id', 'CASCADE', 'CASCADE');
              $this->addForeignKey('bus_stop_surface_type', 'bus_stop', 'surface_type_id', 'surface_type', 'surface_type_id', 'CASCADE', 'CASCADE');
              $this->addForeignKey('bus_stop_state_common', 'bus_stop', 'state_common_id', 'state_common', 'state_common_id', 'CASCADE', 'CASCADE');
          }
  
          /**
           * @inheritdoc
           */
          public function down()
          {
              $this->dropForeignKey('bus_stop_road', 'bus_stop');
              $this->dropForeignKey('bus_stop_region', 'bus_stop');
              $this->dropForeignKey('bus_stop_settlement', 'bus_stop');
              $this->dropForeignKey('bus_stop_surface_type', 'bus_stop');
              $this->dropForeignKey('bus_stop_state_common', 'bus_stop');
              $this->dropTable('bus_stop');
          }
      }