m240816_231235_obras_clave_unique.php 886 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. use yii\db\Migration;
  3. /**
  4. * Class m240816_231235_obras_clave_unique
  5. */
  6. class m240816_231235_obras_clave_unique extends Migration
  7. {
  8. /**
  9. * {@inheritdoc}
  10. */
  11. public function safeUp()
  12. {
  13. $this->addColumn('Obra', 'clave', $this->string());
  14. $this->createIndex(
  15. 'id-claveObra-unique',
  16. 'Obra',
  17. 'clave',
  18. true
  19. );
  20. }
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public function safeDown()
  25. {
  26. $this->dropIndex(
  27. 'id-claveObra-unique',
  28. 'Obra'
  29. );
  30. $this->dropColumn('Obra', 'clave');
  31. }
  32. /*
  33. // Use up()/down() to run migration code without a transaction.
  34. public function up()
  35. {
  36. }
  37. public function down()
  38. {
  39. echo "m240816_231235_obras_clave_unique cannot be reverted.\n";
  40. return false;
  41. }
  42. */
  43. }