Blame view

console/migrations/m170313_092544_create_user_data_table.php 983 Bytes
c237629a   Anastasia   first commit
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
  <?php
  
  use yii\db\Migration;
  
  /**
   * Handles the creation of table `user_data`.
   */
  class m170313_092544_create_user_data_table extends Migration
  {
      /**
       * @inheritdoc
       */
      public function safeUp()
      {
          $this->createTable('user_data', [
              'user_id' => $this->integer()->notNull(),
              'name' => $this->string(),
              'surname' => $this->string(),
              'image' => $this->string(),
              'email' => $this->string(),
              'phone' => $this->string(),
              'created_at' => $this->integer(),
              'updated_at' => $this->integer(),
              'visited_at' => $this->integer(),
          ]);
          
          $this->addForeignKey('user_data_to_user', 'user_data', 'user_id', 'user', 'id', 'CASCADE', 'CASCADE');
          $this->createIndex('user_id_uk', 'user_data', 'user_id', true);
      }
  
      /**
       * @inheritdoc
       */
      public function safeDown()
      {
          $this->dropTable('user_data');
      }
  }