forge->dropColumn('albaranes', [ 'pedido_id', 'presupuesto_id', 'presupuesto_direccion_id', 'total' ]); $this->forge->addColumn('albaranes', [ 'fecha_albaran' => [ 'type' => 'DATE', 'null' => true, 'after' => 'numero_albaran' ], 'envio_id' => [ 'type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true, 'after' => 'fecha_albaran' ] ]); // AƱadir foreign key a envios con ON DELETE SET NULL $this->db->query('ALTER TABLE `albaranes` ADD CONSTRAINT `fk_albaranes_envio_id` FOREIGN KEY (`envio_id`) REFERENCES `envios`(`id`) ON DELETE SET NULL ON UPDATE CASCADE'); // --- Tabla albaranes_lineas --- $this->forge->dropColumn('albaranes_lineas', ['cajas', 'ejemplares_por_caja']); $this->forge->addColumn('albaranes_lineas', [ 'iva_reducido' => [ 'type' => 'TINYINT', 'constraint' => 1, 'default' => 0, 'null' => false, 'after' => 'precio_unidad' ] ]); } public function down() { // Deshacer cambios tabla albaranes $this->forge->dropForeignKey('albaranes', 'fk_albaranes_envio_id'); $this->forge->dropColumn('albaranes', ['envio_id', 'fecha_albaran']); $this->forge->addColumn('albaranes', [ 'pedido_id' => [ 'type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true, ], 'presupuesto_id' => [ 'type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true, ], 'presupuesto_direccion_id' => [ 'type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true, ], 'total' => [ 'type' => 'DOUBLE', 'null' => true, ], ]); // Deshacer cambios tabla albaranes_lineas $this->forge->dropColumn('albaranes_lineas', ['iva_reducido']); $this->forge->addColumn('albaranes_lineas', [ 'cajas' => [ 'type' => 'INT', 'null' => true, ], 'ejemplares_por_caja' => [ 'type' => 'INT', 'null' => true, ], ]); } }