Advertisement
Sdelkadrom

Untitled

Jan 20th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. <?php
  2.  
  3. use Phinx\Util\Literal;
  4. use Phinx\Migration\AbstractMigration;
  5.  
  6. class TableApartmentObjType extends AbstractMigration
  7. {
  8.  
  9. public function up()
  10. {
  11. $this->execute(
  12. 'UPDATE `ore_nf_apartment_obj_type` ' .
  13. 'SET `icon_file` = "" ' .
  14. 'WHERE `icon_file` IS NULL'
  15. );
  16.  
  17. $table = $this->table('ore_nf_apartment_obj_type');
  18.  
  19. $table->changeColumn(
  20. 'icon_file',
  21. 'string',
  22. [
  23. 'length' => 255,
  24. 'signed' => false,
  25. 'default' => '',
  26. 'null' => false
  27. ]
  28. );
  29.  
  30. $table->changeColumn(
  31. 'parent_id',
  32. 'integer',
  33. [
  34. 'signed' => false,
  35. 'default' => '0',
  36. 'null' => false
  37. ]
  38. );
  39. $table->save();
  40. }
  41.  
  42. public function down()
  43. {
  44. $table = $this->table('ore_nf_apartment_obj_type');
  45.  
  46. $table->changeColumn(
  47. 'icon_file',
  48. 'string',
  49. [
  50. 'length' => 255,
  51. 'null' => true,
  52. 'default' => Literal::from('NULL')
  53. ]
  54. );
  55.  
  56. $table->changeColumn(
  57. 'parent_id',
  58. 'integer',
  59. [
  60. 'signed' => true,
  61. 'default' => '0',
  62. 'null' => false
  63. ]
  64. );
  65. $table->save();
  66. }
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement