12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- use yii\db\Migration;
- /**
- * Class m240718_220523_tabla_servicio_servicio_elemento
- */
- class m240718_220523_tabla_servicio_servicio_elemento extends Migration
- {
- public function safeUp() {
- $this->createTable('Servicio', [
- "id" => $this->string(36),
- "factura" => $this->string(100)->notNull(),
- "tipo" => $this->string(100)->notNull(),
- "descripcion" => $this->text(),
- "fechaServicio" => $this->timestamp()->append(" with time zone"),
- "idTaller" => $this->string(36),
- "idVehiculo" => $this->string(36),
- "creado" => $this->timestamp()->append(" with time zone"),
- "modificado" => $this->timestamp()->append(" with time zone"),
- "eliminado" => $this->timestamp()->append(" with time zone"),
- ]);
- $this->addPrimaryKey("ServicioPK", "Servicio", "id");
-
- $this->addForeignKey("ServicioTallerFK", "Servicio", "idTaller", "Taller", "id");
- $this->addForeignKey("ServicioVehiculoFK", "Servicio", "idVehiculo", "Vehiculo", "id");
-
- $this->createTable('ServicioElemento', [
- "id" => $this->string(36),
- "idServicio" => $this->string(36),
- "elemento" => $this->string(),
- "costo" => $this->string(100),
- "descripcion" => $this->string(100),
- "creado" => $this->timestamp()->append(" with time zone"),
- "modificado" => $this->timestamp()->append(" with time zone"),
- "eliminado" => $this->timestamp()->append(" with time zone"),
- ]);
- $this->addPrimaryKey("ServicioElementoPK", "ServicioElemento", "id");
-
- $this->addForeignKey("ServicioElementoServicioFK", "ServicioElemento", "idServicio", "Servicio", "id");
-
- }
-
- /**
- * {@inheritdoc}
- */
- public function safeDown() {
- $this->dropForeignKey("ServicioElementoServicioFK", "ServicioElemento");
- $this->dropTable('ServicioElemento');
- $this->dropForeignKey("ServicioVehiculoFK", "Servicio");
- $this->dropForeignKey("ServicioTallerFK", "Servicio");
- $this->dropTable('Servicio');
- }
- }
|