m240816_194601_agregacion_unique_en_claves.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. use yii\db\Migration;
  3. /**
  4. * Class m240816_194601_agregacion_unique_en_claves
  5. */
  6. class m240816_194601_agregacion_unique_en_claves extends Migration
  7. {
  8. /**
  9. * {@inheritdoc}
  10. */
  11. public function safeUp()
  12. {
  13. $this->createIndex(
  14. 'id-claveColor-unique',
  15. 'Color',
  16. 'clave',
  17. true
  18. );
  19. $this->createIndex(
  20. 'id-claveMarca-unique',
  21. 'Marca',
  22. 'clave',
  23. true
  24. );
  25. $this->createIndex(
  26. 'id-claveTipoAuto-unique',
  27. 'TipoAuto',
  28. 'clave',
  29. true
  30. );
  31. $this->createIndex(
  32. 'id-claveTipoHerramienta-unique',
  33. 'TipoHerramienta',
  34. 'clave',
  35. true
  36. );
  37. $this->createIndex(
  38. 'id-claveTipoServicio-unique',
  39. 'TipoServicio',
  40. 'clave',
  41. true
  42. );
  43. }
  44. /**
  45. * {@inheritdoc}
  46. */
  47. public function safeDown()
  48. {
  49. $this->dropIndex(
  50. 'id-claveColor-unique',
  51. 'Color'
  52. );
  53. $this->dropIndex(
  54. 'id-claveMarca-unique',
  55. 'Marca'
  56. );
  57. $this->dropIndex(
  58. 'id-claveTipoAuto-unique',
  59. 'TipoAuto'
  60. );
  61. $this->dropIndex(
  62. 'id-claveTipoHerramienta-unique',
  63. 'TipoHerramienta'
  64. );
  65. $this->dropIndex(
  66. 'id-claveTipoServicio-unique',
  67. 'TipoServicio'
  68. );
  69. }
  70. /*
  71. // Use up()/down() to run migration code without a transaction.
  72. public function up()
  73. {
  74. }
  75. public function down()
  76. {
  77. echo "m240816_194601_agregacion_unique_en_claves cannot be reverted.\n";
  78. return false;
  79. }
  80. */
  81. }