Blame view

app/migrations/1.0.4/user_project.php 2.63 KB
e6ca281d   Alex Savenko   migration: delete...
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
  <?php 
  
  use Phalcon\Db\Column;
  use Phalcon\Db\Index;
  use Phalcon\Db\Reference;
  use Phalcon\Mvc\Model\Migration;
  
  /**
   * Class UserProjectMigration_104
   */
  class UserProjectMigration_104 extends Migration
  {
      /**
       * Define the table structure
       *
       * @return void
       */
      public function morph()
      {
          $this->morphTable('user_project', [
                  'columns' => [
                      new Column(
                          'id',
                          [
                              'type' => Column::TYPE_INTEGER,
                              'notNull' => true,
                              'autoIncrement' => true,
                              'first' => true
                          ]
                      ),
                      new Column(
                          'user_id',
                          [
                              'type' => Column::TYPE_INTEGER,
                              'notNull' => true,
                              'after' => 'id'
                          ]
                      ),
                      new Column(
                          'project_id',
                          [
                              'type' => Column::TYPE_INTEGER,
                              'notNull' => true,
                              'after' => 'user_id'
                          ]
                      )
                  ],
                  'indexes' => [
                      new Index('user_project_id_uindex', ['id'], null),
                      new Index('user_project_pkey', ['id'], null)
                  ],
                  'references' => [
                      new Reference(
                          'user_project_project_id_fk',
                          [
                              'referencedTable' => 'project',
                              'columns' => ['project_id'],
                              'referencedColumns' => ['id'],
                              'onUpdate' => '',
                              'onDelete' => ''
                          ]
                      ),
                      new Reference(
                          'user_project_user_id_fk',
                          [
                              'referencedTable' => 'user',
                              'columns' => ['user_id'],
                              'referencedColumns' => ['id'],
                              'onUpdate' => '',
                              'onDelete' => ''
                          ]
                      )
                  ],
              ]
          );
      }
  
      /**
       * Run the migrations
       *
       * @return void
       */
      public function up()
      {
  
      }
  
      /**
       * Reverse the migrations
       *
       * @return void
       */
      public function down()
      {
  
      }
  
  }