12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <?php
- use yii\db\Migration;
- /**
- * Class m240927_010701_Tabla_Incidente_e_IncidenteEmpleado
- */
- class m240927_010701_Tabla_Incidente_e_IncidenteEmpleado extends Migration
- {
- /**
- * {@inheritdoc}
- */
- public function safeUp()
- {
- $this->createTable('Incidente', [
- "id" => $this->string(36),
- "nombre" => $this->string(100)->notNull(),
- "fechaIncidente" => $this->timestamp()->append(" with time zone"),
- "idObra" => $this->string(36),
- "descripcion" => $this->string(100)->notNull(),
- "creado" => $this->timestamp()->append(" with time zone"),
- "modificado" => $this->timestamp()->append(" with time zone"),
- "eliminado" => $this->timestamp()->append(" with time zone"),
- ]);
- $this->addForeignKey("IncidenteObraFK", "Incidente", "idObra", "Obra", "id");
- $this->addPrimaryKey('IncidentePK', 'Incidente', 'id');
- $this->createTable("IncidenteEmpleado", [
- "id" => $this->string(36),
- "idIncidente" => $this->string(36),
- "idEmpleado" => $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('IncidenteEmpleadoPK', 'IncidenteEmpleado', 'id');
- $this->addForeignKey('IncidenteEmpleadoIncidenteFK', 'IncidenteEmpleado', 'idIncidente', 'Incidente', 'id');
- $this->addForeignKey('IncidenteEmpleadoEmpleadoFK', 'IncidenteEmpleado', 'idEmpleado', 'Empleado', 'id');
- }
- /**
- * {@inheritdoc}
- */
- public function safeDown()
- {
- $this->dropForeignKey("IncidenteObraFK", "Incidente");
- $this->dropTable('Incidente');
- $this->dropForeignKey('IncidenteEmpleadoIncidenteFK', "IncidenteEmpleado");
- $this->dropForeignKey('IncidenteEmpleadoEmpleadoFK', "IncidenteEmpleado");
- $this->dropTable('IncidenteEmpleado');
- }
- /*
- // Use up()/down() to run migration code without a transaction.
- public function up()
- {
- }
- public function down()
- {
- echo "m240927_010701_Tabla_Incidente_e_IncidenteEmpleado cannot be reverted.\n";
- return false;
- }
- */
- }
|