You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 8 години
преди 8 години
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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('/^add_(.+)_columns?_to_(.+)_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 adding <?= $columns ?> to 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('_addColumns', [
  32. 'table' => $table,
  33. 'fields' => $fields,
  34. 'foreignKeys' => $foreignKeys,
  35. ])
  36. ?>
  37. }
  38. /**
  39. * @inheritdoc
  40. */
  41. public function down()
  42. {
  43. <?= $this->render('_dropColumns', [
  44. 'table' => $table,
  45. 'fields' => $fields,
  46. 'foreignKeys' => $foreignKeys,
  47. ])
  48. ?>
  49. }
  50. }