m240718_220523_tabla_servicio_servicio_elemento.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. use yii\db\Migration;
  3. /**
  4. * Class m240718_220523_tabla_servicio_servicio_elemento
  5. */
  6. class m240718_220523_tabla_servicio_servicio_elemento extends Migration
  7. {
  8. public function safeUp() {
  9. $this->createTable('Servicio', [
  10. "id" => $this->string(36),
  11. "factura" => $this->string(100)->notNull(),
  12. "tipo" => $this->string(100)->notNull(),
  13. "descripcion" => $this->text(),
  14. "fechaServicio" => $this->timestamp()->append(" with time zone"),
  15. "idTaller" => $this->string(36),
  16. "idVehiculo" => $this->string(36),
  17. "creado" => $this->timestamp()->append(" with time zone"),
  18. "modificado" => $this->timestamp()->append(" with time zone"),
  19. "eliminado" => $this->timestamp()->append(" with time zone"),
  20. ]);
  21. $this->addPrimaryKey("ServicioPK", "Servicio", "id");
  22. $this->addForeignKey("ServicioTallerFK", "Servicio", "idTaller", "Taller", "id");
  23. $this->addForeignKey("ServicioVehiculoFK", "Servicio", "idVehiculo", "Vehiculo", "id");
  24. $this->createTable('ServicioElemento', [
  25. "id" => $this->string(36),
  26. "idServicio" => $this->string(36),
  27. "elemento" => $this->string(),
  28. "costo" => $this->string(100),
  29. "descripcion" => $this->string(100),
  30. "creado" => $this->timestamp()->append(" with time zone"),
  31. "modificado" => $this->timestamp()->append(" with time zone"),
  32. "eliminado" => $this->timestamp()->append(" with time zone"),
  33. ]);
  34. $this->addPrimaryKey("ServicioElementoPK", "ServicioElemento", "id");
  35. $this->addForeignKey("ServicioElementoServicioFK", "ServicioElemento", "idServicio", "Servicio", "id");
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function safeDown() {
  41. $this->dropForeignKey("ServicioElementoServicioFK", "ServicioElemento");
  42. $this->dropTable('ServicioElemento');
  43. $this->dropForeignKey("ServicioVehiculoFK", "Servicio");
  44. $this->dropForeignKey("ServicioTallerFK", "Servicio");
  45. $this->dropTable('Servicio');
  46. }
  47. }