55 lines
1.1KB

  1. <?php
  2. /**
  3. * This view is used by console/controllers/MigrateController.php
  4. * The following variables are available in this view:
  5. */
  6. /* @var $className string the new migration class name without namespace */
  7. /* @var $namespace string the new migration class namespace */
  8. /* @var $table string the name table */
  9. /* @var $fields array the fields */
  10. preg_match('/^drop_(.+)_columns?_from_(.+)_table$/', $name, $matches);
  11. $columns = $matches[1];
  12. echo "<?php\n";
  13. if (!empty($namespace)) {
  14. echo "\nnamespace {$namespace};\n";
  15. }
  16. ?>
  17. use yii\db\Migration;
  18. /**
  19. * Handles dropping <?= $columns ?> from table `<?= $table ?>`.
  20. <?= $this->render('_foreignTables', [
  21. 'foreignKeys' => $foreignKeys,
  22. ]) ?>
  23. */
  24. class <?= $className ?> extends Migration
  25. {
  26. /**
  27. * @inheritdoc
  28. */
  29. public function up()
  30. {
  31. <?= $this->render('_dropColumns', [
  32. 'table' => $table,
  33. 'fields' => $fields,
  34. 'foreignKeys' => $foreignKeys,
  35. ])
  36. ?>
  37. }
  38. /**
  39. * @inheritdoc
  40. */
  41. public function down()
  42. {
  43. <?= $this->render('_addColumns', [
  44. 'table' => $table,
  45. 'fields' => $fields,
  46. 'foreignKeys' => $foreignKeys,
  47. ])
  48. ?>
  49. }
  50. }