20190525151522_my_new_migration.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. use Phinx\Migration\AbstractMigration;
  3. class MyNewMigration extends AbstractMigration
  4. {
  5. /**
  6. * Change Method.
  7. *
  8. * Write your reversible migrations using this method.
  9. *
  10. * More information on writing migrations is available here:
  11. * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
  12. *
  13. * The following commands can be used in this method and Phinx will
  14. * automatically reverse them when rolling back:
  15. *
  16. * createTable
  17. * renameTable
  18. * addColumn
  19. * addCustomColumn
  20. * renameColumn
  21. * addIndex
  22. * addForeignKey
  23. *
  24. * Any other destructive changes will result in an error when trying to
  25. * rollback the migration.
  26. *
  27. * Remember to call "create()" or "update()" and NOT "save()" when working
  28. * with the Table class.
  29. */
  30. // public function change()
  31. // {
  32. //
  33. // }
  34. public function up() {
  35. $table = $this->table('user');
  36. // $table->addColumn('user_id', 'integer', ['length' => '10'])
  37. // ->addColumn('vip_id', 'integer', ['length' => \Phinx\Db\Adapter\MysqlAdapter::INT_BIG])
  38. // ->update();
  39. $table->addColumn('city', 'string',['length' => 255])
  40. ->addIndex(['city'],[
  41. 'unique' => true,
  42. 'name' => 'idx_users_email'])
  43. ->update();
  44. }
  45. public function down() {
  46. }
  47. }