Commit da19e117dd5936b24eb7d1bce1e443d26c5d09cb

Authored by Alex Savenko
1 parent a14aee59

add migrations for user_project table

app/migrations/1.0.3/album.php 0 → 100644
  1 +<?php
  2 +
  3 +use Phalcon\Db\Column;
  4 +use Phalcon\Db\Index;
  5 +use Phalcon\Db\Reference;
  6 +use Phalcon\Mvc\Model\Migration;
  7 +
  8 +/**
  9 + * Class AlbumMigration_103
  10 + */
  11 +class AlbumMigration_103 extends Migration
  12 +{
  13 + /**
  14 + * Define the table structure
  15 + *
  16 + * @return void
  17 + */
  18 + public function morph()
  19 + {
  20 + $this->morphTable('album', [
  21 + 'columns' => [
  22 + new Column(
  23 + 'id',
  24 + [
  25 + 'type' => Column::TYPE_INTEGER,
  26 + 'notNull' => true,
  27 + 'autoIncrement' => true,
  28 + 'first' => true
  29 + ]
  30 + ),
  31 + new Column(
  32 + 'title',
  33 + [
  34 + 'type' => Column::TYPE_VARCHAR,
  35 + 'size' => 255,
  36 + 'after' => 'id'
  37 + ]
  38 + ),
  39 + new Column(
  40 + 'created_at',
  41 + [
  42 + 'type' => Column::TYPE_TIMESTAMP,
  43 + 'size' => 1,
  44 + 'after' => 'title'
  45 + ]
  46 + ),
  47 + new Column(
  48 + 'updated_at',
  49 + [
  50 + 'type' => Column::TYPE_TIMESTAMP,
  51 + 'size' => 1,
  52 + 'after' => 'created_at'
  53 + ]
  54 + )
  55 + ],
  56 + 'indexes' => [
  57 + new Index('album_pkey', ['id'], null)
  58 + ],
  59 + ]
  60 + );
  61 + }
  62 +
  63 + /**
  64 + * Run the migrations
  65 + *
  66 + * @return void
  67 + */
  68 + public function up()
  69 + {
  70 +
  71 + }
  72 +
  73 + /**
  74 + * Reverse the migrations
  75 + *
  76 + * @return void
  77 + */
  78 + public function down()
  79 + {
  80 +
  81 + }
  82 +
  83 +}
... ...
app/migrations/1.0.3/photo.php 0 → 100644
  1 +<?php
  2 +
  3 +use Phalcon\Db\Column;
  4 +use Phalcon\Db\Index;
  5 +use Phalcon\Db\Reference;
  6 +use Phalcon\Mvc\Model\Migration;
  7 +
  8 +/**
  9 + * Class PhotoMigration_103
  10 + */
  11 +class PhotoMigration_103 extends Migration
  12 +{
  13 + /**
  14 + * Define the table structure
  15 + *
  16 + * @return void
  17 + */
  18 + public function morph()
  19 + {
  20 + $this->morphTable('photo', [
  21 + 'columns' => [
  22 + new Column(
  23 + 'id',
  24 + [
  25 + 'type' => Column::TYPE_INTEGER,
  26 + 'notNull' => true,
  27 + 'autoIncrement' => true,
  28 + 'first' => true
  29 + ]
  30 + ),
  31 + new Column(
  32 + 'title',
  33 + [
  34 + 'type' => Column::TYPE_VARCHAR,
  35 + 'size' => 255,
  36 + 'after' => 'id'
  37 + ]
  38 + ),
  39 + new Column(
  40 + 'album_id',
  41 + [
  42 + 'type' => Column::TYPE_INTEGER,
  43 + 'after' => 'title'
  44 + ]
  45 + ),
  46 + new Column(
  47 + 'created_at',
  48 + [
  49 + 'type' => Column::TYPE_TIMESTAMP,
  50 + 'size' => 1,
  51 + 'after' => 'album_id'
  52 + ]
  53 + ),
  54 + new Column(
  55 + 'updated_at',
  56 + [
  57 + 'type' => Column::TYPE_TIMESTAMP,
  58 + 'size' => 1,
  59 + 'after' => 'created_at'
  60 + ]
  61 + )
  62 + ],
  63 + 'indexes' => [
  64 + new Index('photo_pkey', ['id'], null)
  65 + ],
  66 + 'references' => [
  67 + new Reference(
  68 + 'photo_album_id_fkey',
  69 + [
  70 + 'referencedTable' => 'album',
  71 + 'columns' => ['album_id'],
  72 + 'referencedColumns' => ['id'],
  73 + 'onUpdate' => '',
  74 + 'onDelete' => ''
  75 + ]
  76 + )
  77 + ],
  78 + ]
  79 + );
  80 + }
  81 +
  82 + /**
  83 + * Run the migrations
  84 + *
  85 + * @return void
  86 + */
  87 + public function up()
  88 + {
  89 +
  90 + }
  91 +
  92 + /**
  93 + * Reverse the migrations
  94 + *
  95 + * @return void
  96 + */
  97 + public function down()
  98 + {
  99 +
  100 + }
  101 +
  102 +}
... ...
app/migrations/1.0.3/project.php 0 → 100644
  1 +<?php
  2 +
  3 +use Phalcon\Db\Column;
  4 +use Phalcon\Db\Index;
  5 +use Phalcon\Db\Reference;
  6 +use Phalcon\Mvc\Model\Migration;
  7 +
  8 +/**
  9 + * Class ProjectMigration_103
  10 + */
  11 +class ProjectMigration_103 extends Migration
  12 +{
  13 + /**
  14 + * Define the table structure
  15 + *
  16 + * @return void
  17 + */
  18 + public function morph()
  19 + {
  20 + $this->morphTable('project', [
  21 + 'columns' => [
  22 + new Column(
  23 + 'id',
  24 + [
  25 + 'type' => Column::TYPE_INTEGER,
  26 + 'notNull' => true,
  27 + 'autoIncrement' => true,
  28 + 'first' => true
  29 + ]
  30 + ),
  31 + new Column(
  32 + 'name',
  33 + [
  34 + 'type' => Column::TYPE_VARCHAR,
  35 + 'size' => 255,
  36 + 'after' => 'id'
  37 + ]
  38 + ),
  39 + new Column(
  40 + 'user_id',
  41 + [
  42 + 'type' => Column::TYPE_INTEGER,
  43 + 'after' => 'name'
  44 + ]
  45 + ),
  46 + new Column(
  47 + 'created_at',
  48 + [
  49 + 'type' => Column::TYPE_TIMESTAMP,
  50 + 'size' => 1,
  51 + 'after' => 'user_id'
  52 + ]
  53 + ),
  54 + new Column(
  55 + 'updated_at',
  56 + [
  57 + 'type' => Column::TYPE_TIMESTAMP,
  58 + 'size' => 1,
  59 + 'after' => 'created_at'
  60 + ]
  61 + ),
  62 + new Column(
  63 + 'ga_view_id',
  64 + [
  65 + 'type' => Column::TYPE_INTEGER,
  66 + 'after' => 'updated_at'
  67 + ]
  68 + ),
  69 + new Column(
  70 + 'group',
  71 + [
  72 + 'type' => Column::TYPE_INTEGER,
  73 + 'after' => 'ga_view_id'
  74 + ]
  75 + )
  76 + ],
  77 + 'indexes' => [
  78 + new Index('project_pkey', ['id'], null)
  79 + ],
  80 + 'references' => [
  81 + new Reference(
  82 + 'project_fkey_user_id',
  83 + [
  84 + 'referencedTable' => 'user',
  85 + 'columns' => ['user_id'],
  86 + 'referencedColumns' => ['id'],
  87 + 'onUpdate' => '',
  88 + 'onDelete' => ''
  89 + ]
  90 + )
  91 + ],
  92 + ]
  93 + );
  94 + }
  95 +
  96 + /**
  97 + * Run the migrations
  98 + *
  99 + * @return void
  100 + */
  101 + public function up()
  102 + {
  103 +
  104 + }
  105 +
  106 + /**
  107 + * Reverse the migrations
  108 + *
  109 + * @return void
  110 + */
  111 + public function down()
  112 + {
  113 +
  114 + }
  115 +
  116 +}
... ...
app/migrations/1.0.3/user.php 0 → 100644
  1 +<?php
  2 +
  3 +use Phalcon\Db\Column;
  4 +use Phalcon\Db\Index;
  5 +use Phalcon\Db\Reference;
  6 +use Phalcon\Mvc\Model\Migration;
  7 +
  8 +/**
  9 + * Class UserMigration_103
  10 + */
  11 +class UserMigration_103 extends Migration
  12 +{
  13 + /**
  14 + * Define the table structure
  15 + *
  16 + * @return void
  17 + */
  18 + public function morph()
  19 + {
  20 + $this->morphTable('user', [
  21 + 'columns' => [
  22 + new Column(
  23 + 'id',
  24 + [
  25 + 'type' => Column::TYPE_INTEGER,
  26 + 'notNull' => true,
  27 + 'autoIncrement' => true,
  28 + 'first' => true
  29 + ]
  30 + ),
  31 + new Column(
  32 + 'username',
  33 + [
  34 + 'type' => Column::TYPE_VARCHAR,
  35 + 'size' => 1,
  36 + 'after' => 'id'
  37 + ]
  38 + ),
  39 + new Column(
  40 + 'password',
  41 + [
  42 + 'type' => Column::TYPE_VARCHAR,
  43 + 'size' => 1,
  44 + 'after' => 'username'
  45 + ]
  46 + ),
  47 + new Column(
  48 + 'email',
  49 + [
  50 + 'type' => Column::TYPE_VARCHAR,
  51 + 'size' => 255,
  52 + 'after' => 'password'
  53 + ]
  54 + ),
  55 + new Column(
  56 + 'role',
  57 + [
  58 + 'type' => Column::TYPE_VARCHAR,
  59 + 'default' => "User",
  60 + 'notNull' => true,
  61 + 'size' => 1,
  62 + 'after' => 'email'
  63 + ]
  64 + ),
  65 + new Column(
  66 + 'created_at',
  67 + [
  68 + 'type' => Column::TYPE_TIMESTAMP,
  69 + 'size' => 1,
  70 + 'after' => 'role'
  71 + ]
  72 + ),
  73 + new Column(
  74 + 'updated_at',
  75 + [
  76 + 'type' => Column::TYPE_TIMESTAMP,
  77 + 'size' => 1,
  78 + 'after' => 'created_at'
  79 + ]
  80 + )
  81 + ],
  82 + 'indexes' => [
  83 + new Index('name_uniq', ['username'], null),
  84 + new Index('users_pkey', ['id'], null)
  85 + ],
  86 + ]
  87 + );
  88 + }
  89 +
  90 + /**
  91 + * Run the migrations
  92 + *
  93 + * @return void
  94 + */
  95 + public function up()
  96 + {
  97 +
  98 + }
  99 +
  100 + /**
  101 + * Reverse the migrations
  102 + *
  103 + * @return void
  104 + */
  105 + public function down()
  106 + {
  107 +
  108 + }
  109 +
  110 +}
... ...
app/migrations/1.0.3/user_project.php 0 → 100644
  1 +<?php
  2 +
  3 +use Phalcon\Db\Column;
  4 +use Phalcon\Db\Index;
  5 +use Phalcon\Db\Reference;
  6 +use Phalcon\Mvc\Model\Migration;
  7 +
  8 +/**
  9 + * Class UserProjectMigration_103
  10 + */
  11 +class UserProjectMigration_103 extends Migration
  12 +{
  13 + /**
  14 + * Define the table structure
  15 + *
  16 + * @return void
  17 + */
  18 + public function morph()
  19 + {
  20 + $this->morphTable('user_project', [
  21 + 'columns' => [
  22 + new Column(
  23 + 'id',
  24 + [
  25 + 'type' => Column::TYPE_INTEGER,
  26 + 'notNull' => true,
  27 + 'autoIncrement' => true,
  28 + 'first' => true
  29 + ]
  30 + ),
  31 + new Column(
  32 + 'user_id',
  33 + [
  34 + 'type' => Column::TYPE_INTEGER,
  35 + 'notNull' => true,
  36 + 'after' => 'id'
  37 + ]
  38 + ),
  39 + new Column(
  40 + 'project_id',
  41 + [
  42 + 'type' => Column::TYPE_INTEGER,
  43 + 'notNull' => true,
  44 + 'after' => 'user_id'
  45 + ]
  46 + )
  47 + ],
  48 + 'indexes' => [
  49 + new Index('user_project_id_uindex', ['id'], null),
  50 + new Index('user_project_pkey', ['id'], null)
  51 + ],
  52 + 'references' => [
  53 + new Reference(
  54 + 'user_project_project_id_fk',
  55 + [
  56 + 'referencedTable' => 'project',
  57 + 'columns' => ['project_id'],
  58 + 'referencedColumns' => ['id'],
  59 + 'onUpdate' => '',
  60 + 'onDelete' => ''
  61 + ]
  62 + ),
  63 + new Reference(
  64 + 'user_project_user_id_fk',
  65 + [
  66 + 'referencedTable' => 'user',
  67 + 'columns' => ['user_id'],
  68 + 'referencedColumns' => ['id'],
  69 + 'onUpdate' => '',
  70 + 'onDelete' => ''
  71 + ]
  72 + )
  73 + ],
  74 + ]
  75 + );
  76 + }
  77 +
  78 + /**
  79 + * Run the migrations
  80 + *
  81 + * @return void
  82 + */
  83 + public function up()
  84 + {
  85 +
  86 + }
  87 +
  88 + /**
  89 + * Reverse the migrations
  90 + *
  91 + * @return void
  92 + */
  93 + public function down()
  94 + {
  95 +
  96 + }
  97 +
  98 +}
... ...