m230130_220056_redes.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. use yii\db\Migration;
  3. /**
  4. * Class m230130_220056_redes
  5. */
  6. class m230130_220056_redes extends Migration {
  7. /**
  8. * {@inheritdoc}
  9. */
  10. public function safeUp() {
  11. $this->createTable('Red', [
  12. 'idEvento' => $this->integer(),
  13. 'key' => $this->string(50),
  14. 'url' => $this->string(500),
  15. 'redSocial' => $this->string(250)
  16. ]);
  17. $this->addPrimaryKey('RedPK', 'Red', ['idEvento', 'url']);
  18. $this->addForeignKey('RedEventoFK', 'Red', 'idEvento', 'Evento', 'id');
  19. $this->addColumn('Evento', 'ciudad', $this->string(100));
  20. $this->createTable('EventoAccion', [
  21. 'idEvento' => $this->integer(),
  22. 'accion' => $this->string(10)
  23. ]);
  24. $this->addPrimaryKey('EventoAccionPK', 'EventoAccion', ['idEvento', 'accion']);
  25. $this->addForeignKey('EventoAccionEventoFK', 'EventoAccion', 'idEvento', 'Evento', 'id');
  26. $this->alterColumn('Usuario', 'email', $this->string(100));
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function safeDown() {
  32. $this->alterColumn('Usuario', 'email', $this->string(100)->notNull());
  33. $this->dropTable('EventoAccion');
  34. $this->dropForeignKey('EventoAccionEventoFK', 'EventoAccion');
  35. $this->dropPrimaryKey('EventoAccionPK', 'EventoAccion');
  36. $this->dropColumn('Evento', 'ciudad');
  37. $this->dropForeignKey('RedEventoFK', 'Red');
  38. $this->dropPrimaryKey('RedPK', 'Red');
  39. $this->dropTable('Red');
  40. }
  41. }