m230420_191735_notificaciones.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. use yii\db\Migration;
  3. /**
  4. * Class m230420_191735_notificaciones
  5. */
  6. class m230420_191735_notificaciones extends Migration {
  7. /**
  8. * {@inheritdoc}
  9. */
  10. public function safeUp() {
  11. $this->createTable('Notificacion', [
  12. 'id' => $this->primaryKey(),
  13. 'envio' => $this->timestamp().' with time zone',
  14. 'estatus' => $this->string(10),
  15. 'creado' => $this->timestamp().' with time zone',
  16. 'modificado' => $this->timestamp().' with time zone',
  17. 'detalle' => $this->json()
  18. ]);
  19. $this->createTable('NotificacionUsuario', [
  20. 'id' => $this->primaryKey(),
  21. 'idNotificacion' => $this->integer(),
  22. 'idUsuario' => $this->integer(),
  23. 'nombre' => $this->string(100),
  24. 'telefono' => $this->string(10),
  25. 'parametros' => $this->json(),
  26. 'detalle' => $this->json()
  27. ]);
  28. $this->addForeignKey('NotificacionUsuario_idNotificacion_FK', 'NotificacionUsuario', 'idNotificacion', 'Notificacion', 'id');
  29. $this->addForeignKey('NotificacionUsuario_idUsuario_FK', 'NotificacionUsuario', 'idUsuario', 'Usuario', 'id');
  30. }
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public function safeDown() {
  35. $this->dropForeignKey('NotificacionUsuario_idUsuario_FK', 'NotificacionUsuario');
  36. $this->dropForeignKey('NotificacionUsuario_idNotificacion_FK', 'NotificacionUsuario');
  37. $this->dropTable('NotificacionUsuario');
  38. $this->dropTable('Notificacion');
  39. }
  40. }