|
@@ -0,0 +1,114 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+use yii\db\Migration;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Class m240926_231003_tablas_compras_comprasProducto_mermas_nominas
|
|
|
+ */
|
|
|
+class m240926_231003_tablas_compras_comprasProducto_mermas_nominas extends Migration {
|
|
|
+
|
|
|
+ public function safeUp() {
|
|
|
+ $this->createTable('Compra', [
|
|
|
+ "id" => $this->string(36),
|
|
|
+ "idObra" => $this->string(36),
|
|
|
+ "idUsuario" => $this->string(36),
|
|
|
+ "fechaCompra" => $this->timestamp()->append(" with time zone"),
|
|
|
+ "creado" => $this->timestamp()->append(" with time zone"),
|
|
|
+ "modificado" => $this->timestamp()->append(" with time zone"),
|
|
|
+ "eliminado" => $this->timestamp()->append(" with time zone"),
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $this->addPrimaryKey('CompraPK', 'Compra', 'id');
|
|
|
+
|
|
|
+ $this->addForeignKey('CompraObraFK', 'Compra', 'idObra', 'Obra', 'id');
|
|
|
+ $this->addForeignKey('CompraUsuarioFK', 'Compra', 'idUsuario', 'Usuario', 'id');
|
|
|
+
|
|
|
+ $this->createTable('CompraProducto', [
|
|
|
+ "id" => $this->string(36),
|
|
|
+ "idCompra" => $this->string(36),
|
|
|
+ "idUnidadMedida" => $this->string(36),
|
|
|
+ "idPartida" => $this->string(36),
|
|
|
+ "producto" => $this->string(),
|
|
|
+ "cantidad" => $this->string(),
|
|
|
+ "precio" => $this->decimal(10, 2),
|
|
|
+ "descripcion" => $this->text(),
|
|
|
+ "creado" => $this->timestamp()->append(" with time zone"),
|
|
|
+ "modificado" => $this->timestamp()->append(" with time zone"),
|
|
|
+ "eliminado" => $this->timestamp()->append(" with time zone"),
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $this->addPrimaryKey('CompraProductoPK','CompraProducto', 'id');
|
|
|
+
|
|
|
+ $this->addForeignKey('CompraProductoCompraFK', 'CompraProducto', 'idCompra', 'Compra', 'id');
|
|
|
+ $this->addForeignKey('CompraProductoMedidaFK', 'CompraProducto', 'idUnidadMedida', 'UnidadMedida', 'id');
|
|
|
+ $this->addForeignKey('CompraProductoPartidaFK', 'CompraProducto', 'idPartida', 'Partida', 'id');
|
|
|
+
|
|
|
+ $this->createTable('Merma', [
|
|
|
+ "id" => $this->string(36),
|
|
|
+ "idObra" => $this->string(36),
|
|
|
+ "idUnidadMedida" => $this->string(36),
|
|
|
+ "idPartida" => $this->string(36),
|
|
|
+ "idUsuario" => $this->string(36),
|
|
|
+ "producto" => $this->string(),
|
|
|
+ "descripcion" => $this->text(),
|
|
|
+ "cantidad" => $this->string(),
|
|
|
+ "precio" => $this->decimal(10, 2),
|
|
|
+ "creado" => $this->timestamp()->append(" with time zone"),
|
|
|
+ "modificado" => $this->timestamp()->append(" with time zone"),
|
|
|
+ "eliminado" => $this->timestamp()->append(" with time zone"),
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $this->addPrimaryKey('MermaPK', 'Merma', 'id');
|
|
|
+
|
|
|
+ $this->addForeignKey('MermaObraFK', 'Merma', 'idObra', 'Obra', 'id');
|
|
|
+ $this->addForeignKey('MermaUnidadMedidaFK', 'Merma', 'idUnidadMedida', 'UnidadMedida', 'id');
|
|
|
+ $this->addForeignKey('MermaPartidaFK', 'Merma', 'idPartida', 'Partida', 'id');
|
|
|
+ $this->addForeignKey('MermaUsuarioFK', 'Merma', 'idUsuario', 'Usuario', 'id');
|
|
|
+
|
|
|
+ $this->createTable('Nomina', [
|
|
|
+ "id" => $this->string(36),
|
|
|
+ "idEmpleado" => $this->string(36),
|
|
|
+ "idObra" => $this->string(36),
|
|
|
+ "idUsuario" => $this->string(36),
|
|
|
+ "montoPagado" => $this->decimal(10,2),
|
|
|
+ "descuento" => $this->decimal(10,2),
|
|
|
+ "creado" => $this->timestamp()->append(" with time zone"),
|
|
|
+ "fechaPago" => $this->timestamp()->append(" with time zone"),
|
|
|
+ "modificado" => $this->timestamp()->append(" with time zone"),
|
|
|
+ "eliminado" => $this->timestamp()->append(" with time zone"),
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $this->addPrimaryKey('NominaPK', 'Nomina', 'id');
|
|
|
+
|
|
|
+ $this->addForeignKey('NominaObraFK', 'Nomina', 'idObra', 'Obra', 'id');
|
|
|
+ $this->addForeignKey('NominaEmpleadoFK', 'Nomina', 'idEmpleado', 'Empleado', 'id');
|
|
|
+ $this->addForeignKey('NominaUsuarioFK', 'Nomina', 'idUsuario', 'Usuario', 'id');
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public function safeDown() {
|
|
|
+ $this->dropForeignKey('NominaObraFK', 'Nomina');
|
|
|
+ $this->dropForeignKey('NominaEmpleadoFK', 'Nomina');
|
|
|
+ $this->dropForeignKey('NominaUsuarioFK', 'Nomina');
|
|
|
+
|
|
|
+ $this->dropTable('Nomina');
|
|
|
+
|
|
|
+ $this->dropForeignKey('MermaObraFK', 'Merma');
|
|
|
+ $this->dropForeignKey('MermaUnidadMedidaFK', 'Merma');
|
|
|
+ $this->dropForeignKey('MermaPartidaFK', 'Merma');
|
|
|
+ $this->dropForeignKey('MermaUsuarioFK', 'Merma');
|
|
|
+
|
|
|
+ $this->dropTable('Merma');
|
|
|
+
|
|
|
+ $this->dropForeignKey('CompraProductoCompraFK', 'CompraProducto');
|
|
|
+ $this->dropForeignKey('CompraProductoMedidaFK', 'CompraProducto');
|
|
|
+ $this->dropForeignKey('CompraProductoPartidaFK', 'CompraProducto');
|
|
|
+
|
|
|
+ $this->dropTable('CompraProducto');
|
|
|
+
|
|
|
+ $this->dropForeignKey('CompraObraFK', 'Compra');
|
|
|
+ $this->dropForeignKey('CompraUsuarioFK', 'Compra');
|
|
|
+
|
|
|
+ $this->dropTable('Compra');
|
|
|
+ }
|
|
|
+}
|