Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.30 KB | None | 0 0
  1. <?php
  2.  
  3. use Phinx\Migration\AbstractMigration;
  4.  
  5. class Users extends AbstractMigration
  6. {
  7.     /**
  8.      * Change Method.
  9.      *
  10.      * Write your reversible migrations using this method.
  11.      *
  12.      * More information on writing migrations is available here:
  13.      * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
  14.      *
  15.      * The following commands can be used in this method and Phinx will
  16.      * automatically reverse them when rolling back:
  17.      *
  18.      *    createTable
  19.      *    renameTable
  20.      *    addColumn
  21.      *    renameColumn
  22.      *    addIndex
  23.      *    addForeignKey
  24.      *
  25.      * Remember to call "create()" or "update()" and NOT "save()" when working
  26.      * with the Table class.
  27.      */
  28.     public function up()
  29.     {
  30.         $table = $this->table('users',  array(
  31.             'id' => 'user_id',
  32.             'primary_key' => array('user_id', 'user_login', 'user_password')
  33.             )
  34.         );
  35.  
  36.         $table->addColumn('user_login', 'string', array('limit' => 60))
  37.             ->addColumn('user_password', 'string', array('limit' => 60))
  38.             ->addIndex(array('user_login', 'user_password'), array('unique' => true))
  39.             ->save();
  40.  
  41.     }
  42.  
  43.     public function down()
  44.     {
  45.         $this->dropTable('users');
  46.  
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement