From 9c007cca2dc08dbe3b6a559c4b1b5509563cf283 Mon Sep 17 00:00:00 2001 From: Eric Fernandez Date: Wed, 3 Jul 2019 16:55:52 -0300 Subject: [PATCH] all migrations --- README.md | 1 - migrations/20181123153918_v0.1.js | 210 +++++++++++++++++++++++++++++++++++ migrations/20181127121352_v0.1.1.js | 18 +++ migrations/20181129105456_v0.2.js | 19 ++++ migrations/20181130113831_v0.3.js | 15 +++ migrations/20181206105940_v0.1.2.js | 15 +++ migrations/20181210132759_v0.4.js | 15 +++ migrations/20181211152717_0.4.1.js | 16 +++ migrations/20181213153525_0.5.js | 65 +++++++++++ migrations/20181217131259_v0.6.js | 24 ++++ migrations/20181217172010_v0.5.1.js | 15 +++ migrations/20181218155954_0.6.1.js | 19 ++++ migrations/20181221125659_0.6.2.js | 16 +++ migrations/20181221173513_v0.6.3.js | 15 +++ migrations/20181226120323_v0.6.4.js | 15 +++ migrations/20181227171744_v0.6.5.js | 25 +++++ migrations/20181231114424_v0.6.6.js | 36 ++++++ migrations/20190102160859_v0.6.7.js | 15 +++ migrations/20190107163621_v0.6.8.js | 16 +++ migrations/20190108114746_v0.6.9.js | 26 +++++ migrations/20190109123406_v0.6.10.js | 16 +++ migrations/20190109123752_v0.6.11.js | 28 +++++ migrations/20190110100715_v0.6.12.js | 24 ++++ migrations/20190110152626_v0.6.13.js | 16 +++ migrations/20190114160629_v0.6.14.js | 19 ++++ migrations/20190118161051_v0.6.15.js | 17 +++ migrations/20190121125737_v0.6.16.js | 22 ++++ migrations/20190122165422_v0.6.17.js | 35 ++++++ migrations/20190125093429_v0.6.18.js | 16 +++ migrations/20190125102735_v0.6.19.js | 26 +++++ migrations/20190131161852_v0.6.20.js | 18 +++ migrations/20190207113109_v0.7.0.js | 11 ++ migrations/20190208131322_0.7.1.js | 39 +++++++ migrations/20190212103514_v0.7.2.js | 17 +++ migrations/20190215123700_v0.7.3.js | 24 ++++ migrations/20190220100315_v0.7.4.js | 142 +++++++++++++++++++++++ migrations/20190220121752_v0.7.5.js | 17 +++ migrations/20190221092657_v0.7.6.js | 24 ++++ migrations/20190225143232_v0.7.7.js | 14 +++ migrations/20190228111345_v0.7.8.js | 63 +++++++++++ migrations/20190311170816_v0.8.0.js | 23 ++++ migrations/20190412094131_v0.9.0.js | 18 +++ migrations/20190425163004_v0.9.1.js | 17 +++ migrations/20190524103556_v0.10.0.js | 37 ++++++ migrations/20190611150606_v0.11.0.js | 18 +++ 45 files changed, 1296 insertions(+), 1 deletion(-) create mode 100644 migrations/20181123153918_v0.1.js create mode 100644 migrations/20181127121352_v0.1.1.js create mode 100644 migrations/20181129105456_v0.2.js create mode 100644 migrations/20181130113831_v0.3.js create mode 100644 migrations/20181206105940_v0.1.2.js create mode 100644 migrations/20181210132759_v0.4.js create mode 100644 migrations/20181211152717_0.4.1.js create mode 100644 migrations/20181213153525_0.5.js create mode 100644 migrations/20181217131259_v0.6.js create mode 100644 migrations/20181217172010_v0.5.1.js create mode 100644 migrations/20181218155954_0.6.1.js create mode 100644 migrations/20181221125659_0.6.2.js create mode 100644 migrations/20181221173513_v0.6.3.js create mode 100644 migrations/20181226120323_v0.6.4.js create mode 100644 migrations/20181227171744_v0.6.5.js create mode 100644 migrations/20181231114424_v0.6.6.js create mode 100644 migrations/20190102160859_v0.6.7.js create mode 100644 migrations/20190107163621_v0.6.8.js create mode 100644 migrations/20190108114746_v0.6.9.js create mode 100644 migrations/20190109123406_v0.6.10.js create mode 100644 migrations/20190109123752_v0.6.11.js create mode 100644 migrations/20190110100715_v0.6.12.js create mode 100644 migrations/20190110152626_v0.6.13.js create mode 100644 migrations/20190114160629_v0.6.14.js create mode 100644 migrations/20190118161051_v0.6.15.js create mode 100644 migrations/20190121125737_v0.6.16.js create mode 100644 migrations/20190122165422_v0.6.17.js create mode 100644 migrations/20190125093429_v0.6.18.js create mode 100644 migrations/20190125102735_v0.6.19.js create mode 100644 migrations/20190131161852_v0.6.20.js create mode 100644 migrations/20190207113109_v0.7.0.js create mode 100644 migrations/20190208131322_0.7.1.js create mode 100644 migrations/20190212103514_v0.7.2.js create mode 100644 migrations/20190215123700_v0.7.3.js create mode 100644 migrations/20190220100315_v0.7.4.js create mode 100644 migrations/20190220121752_v0.7.5.js create mode 100644 migrations/20190221092657_v0.7.6.js create mode 100644 migrations/20190225143232_v0.7.7.js create mode 100644 migrations/20190228111345_v0.7.8.js create mode 100644 migrations/20190311170816_v0.8.0.js create mode 100644 migrations/20190412094131_v0.9.0.js create mode 100644 migrations/20190425163004_v0.9.1.js create mode 100644 migrations/20190524103556_v0.10.0.js create mode 100644 migrations/20190611150606_v0.11.0.js diff --git a/README.md b/README.md index 6555a0c..87f00a8 100644 --- a/README.md +++ b/README.md @@ -7,4 +7,3 @@ Pasos a seguir instalación y primera migración: - Una vez ejecutado el comando se ha creado el archivo `knexfile.js`, configurar la base de datos deseada. - En consola correr el comando > knex migrate:latest --env nombreConfiguracion - diff --git a/migrations/20181123153918_v0.1.js b/migrations/20181123153918_v0.1.js new file mode 100644 index 0000000..243ced0 --- /dev/null +++ b/migrations/20181123153918_v0.1.js @@ -0,0 +1,210 @@ + +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.createTable('nota_pedido', function(table) { + table.increments(); + table.integer('bomba'); + table.integer('cotizacion'); + table.string('cuitCliente'); + table.string('domicilioStamp'); + table.integer('estado'); + table.dateTime('fechaCarga'); + table.integer('flete'); + table.integer('fob'); + table.decimal('kilometros', 12, 2); + table.string('nombreCliente'); + table.integer('numeroNotaPedido'); + table.integer('responsabilidadIvaCliente'); + table.integer('sucursal'); + table.decimal('total', 12, 2); + table.bigInteger('idCliente').unsigned(); + table.bigInteger('idCotizacion').unsigned(); + table.bigInteger('idDomicilio').unsigned(); + table.bigInteger('idPrecioCondicion').unsigned(); + table.bigInteger('idProveedor').unsigned(); + table.bigInteger('idRemito').unsigned(); + table.bigInteger('idVendedor').unsigned(); + }).createTable('precios_condiciones', function(table) { + table.increments(); + table.boolean('activo'); + table.string('codigo'); + table.string('descripcion'); + table.string('nombre'); + table.date('vigencia'); + table.bigInteger('idListaPrecio').unsigned(); + }).createTable('plazo_pago', function(table) { + table.increments(); + table.boolean('activo'); + table.integer('dias'); + table.integer('item'); + table.bigInteger('idPreciosCondiciones').unsigned(); + }).createTable('articulo_nota_pedido', function(table) { + table.increments(); + table.decimal('cantidad', 12, 2); + table.string('codigo'); + table.boolean('combustible'); + table.decimal('costoUnitario', 12, 2); + table.string('descripcion'); + table.decimal('exentoUnitario', 12, 2); + table.boolean('facturado'); + table.decimal('impuestoInternoUnitario', 12, 2); + table.decimal('impuestoInterno1Unitario', 12, 2); + table.decimal('impuestoInterno2Unitario', 12, 2); + table.integer('item'); + table.decimal('ivaUnitario', 12, 2); + table.decimal('ivaServicioUnitario', 12, 2); + table.string('nombre'); + table.decimal('precio', 12, 4); + table.decimal('precioLista', 12, 2); + table.integer('sector'); + table.integer('rubro'); + table.decimal('tasaIva', 12, 2); + table.bigInteger('idNotaPedido').unsigned(); + }).createTable('boton', function(table) { + table.increments(); + table.string('accion'); + table.string('app'); + table.string('clase'); + table.string('texto'); + }).createTable('chofer', function(table) { + table.increments(); + table.string('dni'); + table.string('nombre'); + table.string('telefono'); + table.bigInteger('idTransportista').unsigned(); + }).createTable('vehiculo', function(table) { + table.increments(); + table.string('capacidad'); + table.string('cisternado'); + table.string('semi'); + table.string('tractor'); + table.bigInteger('idTransportista').unsigned(); + // TODO: Revisar si en los seeds no inserta por ser nombres de campo demasiado largos. + // table.string('seguimientoSatelitalUrl'); + // table.string('seguimientoSatelitalUsuario'); + // table.string('seguimientoSatelitalClave'); + }).createTable('nota-pedido-plazo', function(table) { + table.increments(); + table.integer('dias').unsigned(); + table.bigInteger('idNotaPedido').unsigned(); + }).createTable('seguimiento', function(table) { + table.increments(); + table.string('actividad'); + table.integer('distancia'); + table.dateTime('fecha'); + table.string('latitud'); + table.string('longitud'); + table.string('observaciones'); + table.integer('orden'); + table.bigInteger('idUsuario').unsigned(); + }).createTable('nota-pedido-estado', function(table) { + table.increments(); + table.integer('estado'); + table.dateTime('fecha'); + table.bigInteger('idNotaPedido').unsigned(); + table.integer('idVendedor').unsigned(); + }).createTable('configuracion_terminal', function(table) { + table.increments(); + table.string('terminalKey'); + table.string('valor'); + table.string('variable'); + }).createTable('remito', function(table) { + table.increments(); + table.boolean('anulado'); + table.integer('asiento'); + table.integer('bomba'); + table.decimal('carga', 12, 2); + table.string('cuitCliente'); + table.integer('cuentaContable'); + table.integer('cuentaMadre'); + table.decimal('descuento', 12, 2); + table.integer('destinoVenta'); + table.string('domicilioStamp'); + table.integer('estado'); + table.dateTime('fechaRemito'); + table.integer('flete'); + table.integer('fob'); + table.decimal('importeExento', 12, 2); + table.decimal('importeImpuestoInterno', 12, 2); + table.decimal('importeImpuestoInterno1', 12, 2); + table.decimal('importeImpuestoInterno2', 12, 2); + table.decimal('importeIva', 12, 2); + table.decimal('importeIvaServicios', 12, 2); + table.decimal('importeNeto', 12, 2); + table.decimal('kilometros', 12, 2); + table.integer('lugar'); + table.string('nombreCliente'); + table.integer('numeroLiquidoProducto'); + table.integer('numeroNotaPedido'); + table.integer('numeroRemito'); + table.integer('operacionTipo'); + table.decimal('percepcion', 12, 2); + table.decimal('percepcionIva', 12, 2); + table.integer('planilla'); + table.integer('sucursal'); + table.decimal('redondeo', 12, 2); + table.integer('responsabilidadIvaCliente'); + table.decimal('total', 12, 2); + table.bigInteger('idVendedor').unsigned(); + table.bigInteger('idProveedor').unsigned(); + table.bigInteger('idDomicilio').unsigned(); + table.bigInteger('idCotizacion').unsigned(); + table.bigInteger('idPrecioCondicion').unsigned(); + table.bigInteger('idHojaRuta').unsigned(); + table.bigInteger('idCliente').unsigned(); + table.string('e_hd'); + table.string('c_hd'); + }).createTable('articulo_remito', function(table) { + table.increments(); + table.decimal('cantidad', 12, 2); + table.string('codigo'); + table.boolean('combustible'); + table.decimal('costoUnitario', 12, 2); + table.string('descripcion'); + table.decimal('exentoUnitario', 12, 2); + table.boolean('facturado'); + table.integer('item'); + table.decimal('impuestoInternoUnitario', 12, 2); + table.decimal('impuestoInterno1Unitario', 12, 2); + table.decimal('impuestoInterno2Unitario', 12, 2); + table.decimal('ivaServicioUnitario', 12, 2); + table.decimal('ivaUnitario', 12, 2); + table.string('nombre'); + table.decimal('precio', 12, 4); + table.decimal('precioLista', 12, 2); + table.integer('sector'); + table.integer('rubro'); + table.decimal('tasaIva', 12, 2); + table.bigInteger('idRemito').unsigned(); + }).createTable('hoja_ruta', function(table) { + table.increments(); + table.dateTime('fechaCreacion'); + table.bigInteger('numeroHojaRuta').unsigned(); + table.integer('sucursal').unsigned(); + table.decimal('tarifaFlete', 12, 2); + table.bigInteger('idTransportista').unsigned(); + table.bigInteger('idChofer').unsigned(); + table.bigInteger('idVehiculo').unsigned(); + }) + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema + .dropTable('nota_pedido') + .dropTable('precios_condiciones') + .dropTable('plazo_pago') + .dropTable('articulo_nota_pedido') + .dropTable('boton') + .dropTable('chofer') + .dropTable('vehiculo') + .dropTable('nota-pedido-plazo') + .dropTable('seguimiento') + .dropTable('nota-pedido-estado') + .dropTable('configuracion_terminal') + .dropTable('remito') + .dropTable('articulo_remito') + .dropTable('hoja_ruta') + ]); +}; diff --git a/migrations/20181127121352_v0.1.1.js b/migrations/20181127121352_v0.1.1.js new file mode 100644 index 0000000..560beb3 --- /dev/null +++ b/migrations/20181127121352_v0.1.1.js @@ -0,0 +1,18 @@ + +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.table('APAREMP', function(table) { + table.decimal('latitud', 10, 7); + table.decimal('longitud', 10, 7); + }) + ]) +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema.table('APAREMP', function(table) { + table.dropColumn('latitud'); + table.dropColumn('longitud'); + }) + ]) +}; diff --git a/migrations/20181129105456_v0.2.js b/migrations/20181129105456_v0.2.js new file mode 100644 index 0000000..b0bacd9 --- /dev/null +++ b/migrations/20181129105456_v0.2.js @@ -0,0 +1,19 @@ +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.table('vehiculo', function(table) { + table.boolean('desactivado'); + }).alterTable('chofer', function(table) { + table.boolean('desactivado'); + }) + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema.table('vehiculo', function(table) { + table.dropColumn('desactivado'); + }).alterTable('chofer', function(table) { + table.dropColumn('desactivado'); + }) + ]); +}; diff --git a/migrations/20181130113831_v0.3.js b/migrations/20181130113831_v0.3.js new file mode 100644 index 0000000..e9257a0 --- /dev/null +++ b/migrations/20181130113831_v0.3.js @@ -0,0 +1,15 @@ +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.createTable('cobrador', function(table) { + table.increments(); + table.string('nombre'); + table.boolean('desactivado'); + }) + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema.dropTable('cobrador') + ]); +}; diff --git a/migrations/20181206105940_v0.1.2.js b/migrations/20181206105940_v0.1.2.js new file mode 100644 index 0000000..2af3db8 --- /dev/null +++ b/migrations/20181206105940_v0.1.2.js @@ -0,0 +1,15 @@ +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.createTable('remito-plazo', function(table) { + table.increments(); + table.integer('dias').unsigned(); + table.bigInteger('idRemito').unsigned(); + }) + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema.dropTable('remito-plazo') + ]); +}; diff --git a/migrations/20181210132759_v0.4.js b/migrations/20181210132759_v0.4.js new file mode 100644 index 0000000..06a9a42 --- /dev/null +++ b/migrations/20181210132759_v0.4.js @@ -0,0 +1,15 @@ +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.table('seguimiento', function(table) { + table.integer('sucursal'); + }) + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema.table('seguimiento', function(table) { + table.dropColumn('sucursal'); + }) + ]); +}; diff --git a/migrations/20181211152717_0.4.1.js b/migrations/20181211152717_0.4.1.js new file mode 100644 index 0000000..7d83715 --- /dev/null +++ b/migrations/20181211152717_0.4.1.js @@ -0,0 +1,16 @@ +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.table('ARECIBOS', function(table) { + table.bigInteger('idCobrador').unsigned(); + }) + ]); + +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema.table('ARECIBOS', function(table) { + table.dropColumn('idCobrador'); + }) + ]); +}; diff --git a/migrations/20181213153525_0.5.js b/migrations/20181213153525_0.5.js new file mode 100644 index 0000000..bc5ca58 --- /dev/null +++ b/migrations/20181213153525_0.5.js @@ -0,0 +1,65 @@ + +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema + .table('vehiculo', function(table) { + table.string('codigo'); + table.dropColumn('cisternado'); + }) + .createTable('cisterna', function(table) { + table.increments(); + table.string('codigo'); + table.decimal('capacidad', 12, 2); + table.bigInteger('idVehiculo').unsigned(); + table.bigInteger('idUnidadMedida').unsigned(); + table.bigInteger('idCarga').unsigned(); + }) + .createTable('cisterna_carga', function(table) { + table.increments(); + table.decimal('cantidad', 12, 2); + table.bigInteger('codigoArticulo').unsigned(); + table.bigInteger('codigoSectorArticulo').unsigned(); + }) + .createTable('cisterna_movimiento', function(table) { + table.increments(); + table.dateTime('fecha'); + table.decimal('cantidad', 12, 2); + table.string('metodo'); + table.bigInteger('idCisternaCarga').unsigned(); + }) + .createTable('hoja_ruta_movimiento', function(table) { + table.increments(); + table.string('reciboDescarga'); + table.bigInteger('idRemito').unsigned(); + table.bigInteger('idCisternaMovimiento').unsigned(); + table.bigInteger('idSeguimiento').unsigned(); + }) + .table('nota_pedido', function(table) { + table.bigInteger('idSeguimiento').unsigned(); + }) + .table('hoja_ruta', function(table) { + table.bigInteger('idSeguimiento').unsigned(); + }) + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema + .table('vehiculo', function(table) { + table.string('cisternado'); + table.dropColumn('codigo'); + }) + .table('nota_pedido', function(table) { + table.dropColumn('idSeguimiento'); + }) + .table('hoja_ruta', function(table) { + table.dropColumn('idSeguimiento'); + }) + .dropTable('cisterna') + .dropTable('cisterna_carga') + .dropTable('cisterna_movimiento') + .dropTable('hoja_ruta_movimiento') + + ]); +}; diff --git a/migrations/20181217131259_v0.6.js b/migrations/20181217131259_v0.6.js new file mode 100644 index 0000000..ab1a5ef --- /dev/null +++ b/migrations/20181217131259_v0.6.js @@ -0,0 +1,24 @@ +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema + .raw("ALTER TABLE ARTICULOS ADD id INT IDENTITY(1,1)") + .table('cisterna_carga', function(table) { + table.dropColumn('codigoArticulo'); + table.dropColumn('codigoSectorArticulo'); + table.bigInteger('idProducto').unsigned(); + }) + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema + .table('ARTICULOS', function(table) { + table.dropColumn('id'); + }).table('cisterna_carga', function(table) { + table.dropColumn('idProducto'); + table.bigInteger('codigoArticulo').unsigned(); + table.bigInteger('codigoSectorArticulo').unsigned(); + }) + ]); +}; diff --git a/migrations/20181217172010_v0.5.1.js b/migrations/20181217172010_v0.5.1.js new file mode 100644 index 0000000..d7a481d --- /dev/null +++ b/migrations/20181217172010_v0.5.1.js @@ -0,0 +1,15 @@ +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.table('cisterna', function(table) { + table.boolean('desactivado'); + }) + ]) +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema.table('cisterna', function(table) { + table.dropColumn('desactivado'); + }) + ]) +}; diff --git a/migrations/20181218155954_0.6.1.js b/migrations/20181218155954_0.6.1.js new file mode 100644 index 0000000..d72ea39 --- /dev/null +++ b/migrations/20181218155954_0.6.1.js @@ -0,0 +1,19 @@ +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema + .raw("ALTER TABLE ARECIBOS ADD id INT IDENTITY(1,1)") + .table('ARECIBOS', function(table) { + table.bigInteger('idSeguimiento').unsigned(); + }) + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema + .table('ARECIBOS', function(table) { + table.dropColumn('id'); + table.dropColumn('idSeguimiento'); + }) + ]); +}; diff --git a/migrations/20181221125659_0.6.2.js b/migrations/20181221125659_0.6.2.js new file mode 100644 index 0000000..7ace886 --- /dev/null +++ b/migrations/20181221125659_0.6.2.js @@ -0,0 +1,16 @@ + +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.table('precios_condiciones', function(table) { + table.dropColumn('idListaPrecio') + }).raw("ALTER TABLE precios_condiciones ADD idListaPrecio char(4)") + ]) +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema.table('precios_condiciones', function(table) { + table.dropColumn('idListaPrecio') + }) + ]); +}; diff --git a/migrations/20181221173513_v0.6.3.js b/migrations/20181221173513_v0.6.3.js new file mode 100644 index 0000000..4c89d4b --- /dev/null +++ b/migrations/20181221173513_v0.6.3.js @@ -0,0 +1,15 @@ +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.table('articulo_nota_pedido', function(table) { + table.bigint('idArticulo').unsigned(); + }) + ]) +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema.table('articulo_nota_pedido', function(table) { + table.dropColumn('idArticulo'); + }) + ]) +}; diff --git a/migrations/20181226120323_v0.6.4.js b/migrations/20181226120323_v0.6.4.js new file mode 100644 index 0000000..1e52b35 --- /dev/null +++ b/migrations/20181226120323_v0.6.4.js @@ -0,0 +1,15 @@ +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.table('articulo_remito', function(table) { + table.bigint('idArticulo').unsigned(); + }) + ]) +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema.table('articulo_remito', function(table) { + table.dropColumn('idArticulo'); + }) + ]) +}; diff --git a/migrations/20181227171744_v0.6.5.js b/migrations/20181227171744_v0.6.5.js new file mode 100644 index 0000000..dc55bd3 --- /dev/null +++ b/migrations/20181227171744_v0.6.5.js @@ -0,0 +1,25 @@ +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema + .table('cisterna_movimiento', function(table) { + table.bigint('idRemito').unsigned(); + }).table('remito', function(table) { + table.bigint('idUsuarioProceso').unsigned(); + }).table('vehiculo', function(table) { + table.bigint('idUsuarioProceso').unsigned(); + }) + ]) +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema + .table('cisterna_movimiento', function(table) { + table.dropColumn('idRemito'); + }).table('remito', function(table) { + table.dropColumn('idUsuarioProceso'); + }).table('vehiculo', function(table) { + table.dropColumn('idUsuarioProceso'); + }) + ]) +}; diff --git a/migrations/20181231114424_v0.6.6.js b/migrations/20181231114424_v0.6.6.js new file mode 100644 index 0000000..db69a1b --- /dev/null +++ b/migrations/20181231114424_v0.6.6.js @@ -0,0 +1,36 @@ + +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema + .createTable('a_punto_descarga', function(table) { + table.increments(); + table.bigInteger('id_cliente'); + table.bigInteger('id_da_config_0'); + table.string('descripcion'); + table.string('latitud'); + table.string('longitud'); + table.boolean('desactivado'); + }) + .table('CLIENTES', function(table) { + table.boolean('ES_PROS'); + }) + .createTable('nota_pedido_punto_descarga', function(table) { + table.increments(); + table.bigInteger('idPuntoDescarga').unsigned(); + table.bigInteger('idNotaPedido').unsigned(); + table.bigInteger('idProducto').unsigned(); + table.decimal('cantidad', 12, 2); + }) + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema + .dropTable('a_punto_descarga') + .table('CLIENTES', function(table) { + table.dropColumn('ES_PROS'); + }) + .dropTable('nota_pedido_punto_descarga') + ]); +}; diff --git a/migrations/20190102160859_v0.6.7.js b/migrations/20190102160859_v0.6.7.js new file mode 100644 index 0000000..3c925d9 --- /dev/null +++ b/migrations/20190102160859_v0.6.7.js @@ -0,0 +1,15 @@ +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.table('cisterna_movimiento', function(table) { + table.boolean('anulado'); + }) + ]) +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema.table('cisterna_movimiento', function(table) { + table.dropColumn('anulado'); + }) + ]) +}; diff --git a/migrations/20190107163621_v0.6.8.js b/migrations/20190107163621_v0.6.8.js new file mode 100644 index 0000000..3fed659 --- /dev/null +++ b/migrations/20190107163621_v0.6.8.js @@ -0,0 +1,16 @@ + +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.table('VENDEDORES', function(table) { + table.boolean('ES_COBRADOR'); + }) + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema.table('VENDEDORES', function(table) { + table.dropColumn('ES_COBRADOR'); + }) + ]); +}; diff --git a/migrations/20190108114746_v0.6.9.js b/migrations/20190108114746_v0.6.9.js new file mode 100644 index 0000000..7bc2d8f --- /dev/null +++ b/migrations/20190108114746_v0.6.9.js @@ -0,0 +1,26 @@ +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema + .table('cisterna', function(table) { + table.dropColumn('idCarga'); + }) + .table('cisterna_carga', function(table) { + table.bigInteger('idCisterna').unsigned(); + table.date('fechaReparto'); + }) + ]) +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema + .table('cisterna', function(table) { + table.bigInteger('idCarga'); + }) + .table('cisterna_carga', function(table) { + table + .dropColumn('idCisterna') + .dropColumn('fechaReparto'); + }) + ]) +}; diff --git a/migrations/20190109123406_v0.6.10.js b/migrations/20190109123406_v0.6.10.js new file mode 100644 index 0000000..7b23dd7 --- /dev/null +++ b/migrations/20190109123406_v0.6.10.js @@ -0,0 +1,16 @@ + +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.table('VENDEDORES', function(table) { + table.boolean('desactivado'); + }) + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema.table('VENDEDORES', function(table) { + table.dropColumn('desactivado'); + }) + ]); +}; diff --git a/migrations/20190109123752_v0.6.11.js b/migrations/20190109123752_v0.6.11.js new file mode 100644 index 0000000..8d34945 --- /dev/null +++ b/migrations/20190109123752_v0.6.11.js @@ -0,0 +1,28 @@ + +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.createTable('login', function(table) { + table.increments(); + table.string('username'); + table.string('password'); + table.boolean('activo'); + }).table('VENDEDORES', function(table) { + table.bigInteger('idLogin').unsigned(); + }).table('chofer', function(table) { + table.bigInteger('idLogin').unsigned(); + }) + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema + .dropTable('login') + .table('vendedores', function(table) { + table.dropColumn('idLogin'); + }) + .table('chofer', function(table) { + table.dropColumn('idLogin'); + }) + ]); +}; diff --git a/migrations/20190110100715_v0.6.12.js b/migrations/20190110100715_v0.6.12.js new file mode 100644 index 0000000..ccc6147 --- /dev/null +++ b/migrations/20190110100715_v0.6.12.js @@ -0,0 +1,24 @@ +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema + .table('vehiculo', function(table) { + table.dropColumn('idUsuarioProceso'); + }) + .table('cisterna_carga', function(table) { + table.bigInteger('idUsuarioProceso'); + table.boolean('confirmado'); + }) + ]) +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema + .table('vehiculo', function(table) { + table.bigint('idUsuarioProceso').unsigned(); + }) + .table('cisterna_carga', function(table) { + table.dropColumns('idUsuarioProceso', 'confirmado'); + }) + ]) +}; diff --git a/migrations/20190110152626_v0.6.13.js b/migrations/20190110152626_v0.6.13.js new file mode 100644 index 0000000..da8b2db --- /dev/null +++ b/migrations/20190110152626_v0.6.13.js @@ -0,0 +1,16 @@ +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.table('login', function(table) { + table.dateTime('ultimoLogin'); + table.string('token'); + }) + ]) +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema.table('login', function(table) { + table.dropColumns('ultimoLogin', 'token'); + }) + ]); +}; diff --git a/migrations/20190114160629_v0.6.14.js b/migrations/20190114160629_v0.6.14.js new file mode 100644 index 0000000..4ea78b7 --- /dev/null +++ b/migrations/20190114160629_v0.6.14.js @@ -0,0 +1,19 @@ + +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.table('hoja_ruta', function(table) { + //0=disponible 1=asignado 2=terminado + table.integer('estado').unsigned(); + table.date('fechaReparto'); + }) + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema.table('hoja_ruta', function(table) { + table.dropColumn('estado'); + table.dropColumn('fechaReparto'); + }) + ]); +}; diff --git a/migrations/20190118161051_v0.6.15.js b/migrations/20190118161051_v0.6.15.js new file mode 100644 index 0000000..27c4918 --- /dev/null +++ b/migrations/20190118161051_v0.6.15.js @@ -0,0 +1,17 @@ + +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.createTable('tipo_documento', function(table) { + table.integer('id').unsigned().primary(); + table.string('descripcion'); + table.string('orden'); + table.boolean('activo'); + }) + ]) +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema.dropTable('tipo_documento') + ]); +}; diff --git a/migrations/20190121125737_v0.6.16.js b/migrations/20190121125737_v0.6.16.js new file mode 100644 index 0000000..20e20ff --- /dev/null +++ b/migrations/20190121125737_v0.6.16.js @@ -0,0 +1,22 @@ +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema + .table('articulo_remito', function(table) { + table.integer('cantidadDescargada'); + }).table('remito', function(table) { + table.boolean('rechazado'); + table.string('motivoRechazo'); + }) + ]) +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema + .table('articulo_remito', function(table) { + table.dropColumn('cantidadDescargada'); + }).table('remito', function(table) { + table.dropColumns('rechazado', 'motivoRechazo'); + }) + ]) +}; diff --git a/migrations/20190122165422_v0.6.17.js b/migrations/20190122165422_v0.6.17.js new file mode 100644 index 0000000..900103f --- /dev/null +++ b/migrations/20190122165422_v0.6.17.js @@ -0,0 +1,35 @@ +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.table('hoja_ruta', function(table) { + table.decimal('kmInicialVehiculo', 18, 4); + table.decimal('kmFinalVehiculo', 18, 4) + table.decimal('aforadorInicialVehiculo', 18, 4); + table.decimal('aforadorFinalVehiculo', 18, 4) + table.decimal('cantidadDescargaPorGravedad', 18, 4); + table.decimal('litrosDescargadosPorGravedad', 18, 4); + table.decimal('litrosCombustibleParaMovilidad', 18, 4); + table.string('precintoBocaUno'); + table.string('precintoBocaDos'); + table.string('precintoBocaTres'); + }) + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema.table('hoja_ruta', function(table) { + table.dropColumns( + 'kmInicialVehiculo', + 'kmFinalVehiculo', + 'aforadorInicialVehiculo', + 'aforadorFinalVehiculo', + 'cantidadDescargaPorGravedad', + 'litrosDescargadosPorGravedad', + 'litrosCombustibleParaMovilidad', + 'precintoBocaUno', + 'precintoBocaDos', + 'precintoBocaTres' + ); + }) + ]); +}; diff --git a/migrations/20190125093429_v0.6.18.js b/migrations/20190125093429_v0.6.18.js new file mode 100644 index 0000000..ccd78a7 --- /dev/null +++ b/migrations/20190125093429_v0.6.18.js @@ -0,0 +1,16 @@ + +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.table('chofer', function(table) { + table.bigInteger('idTipoDocumento').unsigned(); + }) + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema.table('chofer', function(table) { + table.dropColumn('idTipoDocumento'); + }) + ]); +}; diff --git a/migrations/20190125102735_v0.6.19.js b/migrations/20190125102735_v0.6.19.js new file mode 100644 index 0000000..35a66f0 --- /dev/null +++ b/migrations/20190125102735_v0.6.19.js @@ -0,0 +1,26 @@ + +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema + .table('VENDEDORES', function(table) { + //Puede ser 1=vendedor, 2=cobrador, 3=ambos + table.integer('rol'); + table.decimal('comisionCobrador', 12, 2); + }) + .table('CLIENTES', function(table) { + table.bigInteger('idCobrador').unsigned(); + }) + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema + .table('VENDEDORES', function(table) { + table.dropColumns('rol', 'comisionCobrador'); + }) + .table('CLIENTES', function(table) { + table.dropColumn('idCobrador'); + }) + ]); +}; diff --git a/migrations/20190131161852_v0.6.20.js b/migrations/20190131161852_v0.6.20.js new file mode 100644 index 0000000..89da68d --- /dev/null +++ b/migrations/20190131161852_v0.6.20.js @@ -0,0 +1,18 @@ +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema + .raw("ALTER TABLE ADETREC ADD id INT IDENTITY(1,1)") + .table('ADETREC', function(table) { + table.bigInteger('idArecibos'); + }) + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema + .table('ADETREC', function(table) { + table.dropColumns('id', 'idArecibos'); + }) + ]); +}; diff --git a/migrations/20190207113109_v0.7.0.js b/migrations/20190207113109_v0.7.0.js new file mode 100644 index 0000000..7ea0143 --- /dev/null +++ b/migrations/20190207113109_v0.7.0.js @@ -0,0 +1,11 @@ +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.raw('UPDATE VENDEDORES SET desactivado = 0, rol = 1') + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema.raw('UPDATE VENDEDORES SET desactivado = null, rol = null') + ]); +}; diff --git a/migrations/20190208131322_0.7.1.js b/migrations/20190208131322_0.7.1.js new file mode 100644 index 0000000..8acb7f3 --- /dev/null +++ b/migrations/20190208131322_0.7.1.js @@ -0,0 +1,39 @@ +exports.up = function(knex, Promise) { + return knex.schema.table('AVENDCLI', function(table) { + table.string('domicilio'); + table.bigInteger('idLocalidad').unsigned(); + table.bigInteger('idProvincia').unsigned(); + table.integer('codigoPostal').unsigned(); + table.string('telefono'); + table.integer('dni'); + table.boolean('desactivado').notNullable().defaultTo(0); + table.tinyint('turno').notNullable().defaultTo(0); + //Puede ser 1=vendedor, 2=cobrador, 3=ambos + table.integer('rol').notNullable().defaultTo(1); + table.bigInteger('idLogin').unsigned(); + table.decimal('comisionVendedor', 12, 2).notNullable().defaultTo(0); + table.decimal('comisionCobrador', 12, 2).notNullable().defaultTo(0); + }).raw("ALTER TABLE AVENDCLI ADD id INT IDENTITY(1,1)") +}; + +exports.down = function(knex, Promise) { + // PARA HACER FUNCIONAR ESTE ROLLBACK HAY QUE BORRAR MANUALMENTE LAS CONSTRAINS QUE SE + // CREAN PARA SER VALORES POR DEFECTO + return knex.schema.table('AVENDCLI', function(table) { + table.dropColumns( + 'id', + 'domicilio', + 'idLocalidad', + 'idProvincia', + 'codigoPostal', + 'telefono', + 'dni', + 'idLogin', + 'desactivado', + 'turno', + 'rol', + 'comisionVendedor', + 'comisionCobrador' + ); + }) +}; diff --git a/migrations/20190212103514_v0.7.2.js b/migrations/20190212103514_v0.7.2.js new file mode 100644 index 0000000..cf5c242 --- /dev/null +++ b/migrations/20190212103514_v0.7.2.js @@ -0,0 +1,17 @@ + +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.table('seguimiento', function(table) { + //KM RECORRIDOS DESDE EL PUNTO ANTERIOR O DESDE LA EMPRESA + table.decimal('kmRecorridos', 18, 4); + }) + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema.table('seguimiento', function(table) { + table.dropColumn('kmRecorridos'); + }) + ]); +}; diff --git a/migrations/20190215123700_v0.7.3.js b/migrations/20190215123700_v0.7.3.js new file mode 100644 index 0000000..58357cf --- /dev/null +++ b/migrations/20190215123700_v0.7.3.js @@ -0,0 +1,24 @@ + +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema + .table('nota_pedido', function(table) { + table.string('observaciones'); + }) + .table('remito', function(table) { + table.string('observaciones'); + }) + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema + .table('nota_pedido', function(table) { + table.dropColumn('observaciones'); + }) + .table('remito', function(table) { + table.dropColumn('observaciones'); + }) + ]); +}; diff --git a/migrations/20190220100315_v0.7.4.js b/migrations/20190220100315_v0.7.4.js new file mode 100644 index 0000000..e4ba9c5 --- /dev/null +++ b/migrations/20190220100315_v0.7.4.js @@ -0,0 +1,142 @@ +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.raw( + "if not exists (SELECT * FROM dbo.sysobjects where id = object_id("+ + "N'dbo.[ACOBYPAG_VENCIMIENTOS]') and OBJECTPROPERTY(id, N'IsTable') = 1) begin "+ + "CREATE TABLE ACOBYPAG_VENCIMIENTOS(" + + "[CYV] [char](1) NOT NULL," + + "[COD] [int] NOT NULL," + + "[FEP] [smalldatetime] NOT NULL," + + "[TIP] [char](1) NOT NULL," + + "[TCO] [char](2) NOT NULL," + + "[SUC] [int] NOT NULL," + + "[NCO] [bigint] NOT NULL," + + "[NCU] [bigint] NOT NULL," + + "[IPA] [money] NOT NULL," + + "[SAL] [money] NOT NULL," + + "[TCA] [money] NOT NULL," + + "[ZONA] [int] NOT NULL," + + "[FPA] [char](1) NOT NULL," + + "[REC] [bigint] NOT NULL," + + "[REP] [bigint] NOT NULL," + + "[FER] [smalldatetime] NULL," + + "[REM] [bigint] NOT NULL," + + "[FRE] [smalldatetime] NULL," + + "[PRO] [char](1) NOT NULL," + + "[FEV] [datetime] NULL," + + "[ANU] [char](1) NOT NULL," + + "[CCU] [int] NOT NULL," + + "[UCU] [int] NOT NULL," + + "[PLA] [int] NOT NULL," + + "[LUG] [int] NOT NULL," + + "[PFA] [char](1) NOT NULL," + + "[RES] [int] NOT NULL," + + "[LEG] [varchar](15) NOT NULL," + + "[CTA] [int] NOT NULL," + + "[FAR] [bit] NOT NULL," + + "[HOS] [varchar](1) NOT NULL," + + "[E_HD] [varchar](8) NOT NULL," + + "[C_HD] [varchar](1) NOT NULL," + + "[DIC_SEL] [int] NOT NULL," + + "[SALDO_CALC] [money] NOT NULL," + + "[IDLP] [varchar](1) NOT NULL," + + "[ES_CANJE] [bit] NOT NULL," + + "[CAMBIO_APLICADO] [varchar](50) NOT NULL," + + "[TIPO_CANJE] [bit] NOT NULL," + + "[ORD_COM] [int] NOT NULL," + + "[NATHB] [varchar](1) NOT NULL," + + "CONSTRAINT [PK_ACOBYPAG_VENCIMIENTOS] PRIMARY KEY CLUSTERED" + + "(" + + "[CYV] ASC," + + "[COD] ASC," + + "[FEP] ASC," + + "[TIP] ASC," + + "[TCO] ASC," + + "[SUC] ASC," + + "[NCO] ASC," + + "[NCU] ASC" + + ")WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]" + + ") ON [PRIMARY]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_IPA] DEFAULT ((0)) FOR [IPA]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_SAL] DEFAULT ((0)) FOR [SAL]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_TCA] DEFAULT ((1)) FOR [TCA]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_ZONA] DEFAULT (' ') FOR [ZONA]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_FPA] DEFAULT ((1)) FOR [FPA]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_REC] DEFAULT ((0)) FOR [REC]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_REP] DEFAULT ((0)) FOR [REP]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_REM] DEFAULT ((0)) FOR [REM]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_PRO] DEFAULT ('N') FOR [PRO]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_ANU] DEFAULT (' ') FOR [ANU]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_CCU] DEFAULT ((0)) FOR [CCU]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_UCU] DEFAULT ((0)) FOR [UCU]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_PLA] DEFAULT ((0)) FOR [PLA]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_LUG] DEFAULT ((0)) FOR [LUG]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_PFA] DEFAULT ('N') FOR [PFA]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_RES] DEFAULT ((0)) FOR [RES]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_LEG] DEFAULT ('') FOR [LEG]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_CTA] DEFAULT ((0)) FOR [CTA]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_FAR] DEFAULT ((0)) FOR [FAR]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF__ACOBYPAG_VENCIMIENTOS__HOS__383BDA07] DEFAULT ('') FOR [HOS]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF__ACOBYPAG_VENCIMIENTOS__E_HD__50D27DA7] DEFAULT ('') FOR [E_HD]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF__ACOBYPAG_VENCIMIENTOS__C_HD__51C6A1E0] DEFAULT ('') FOR [C_HD]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD DEFAULT ((0)) FOR [DIC_SEL]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD DEFAULT ((0)) FOR [SALDO_CALC]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD DEFAULT ('') FOR [IDLP]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD DEFAULT ((0)) FOR [ES_CANJE]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD DEFAULT ('') FOR [CAMBIO_APLICADO]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD DEFAULT ((0)) FOR [TIPO_CANJE]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD DEFAULT ((0)) FOR [ORD_COM]" + + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD DEFAULT ('') FOR [NATHB]" + + " end" + ).raw( + "if OBJECT_ID('[dbo].[VI_ACOBYPAG_AMAEFACT]') is not null "+ + "begin " + + "drop view VI_ACOBYPAG_AMAEFACT "+ + "end " + + "execute(' " + + "CREATE VIEW [VI_ACOBYPAG_AMAEFACT]" + + "AS " + + "SELECT A.*, A.FEP as FECHA_COMPROBANTE, C.ID_MONEDA AS MONEDA,C.COTIZACION AS COTIZACION," + + "B.COD AS CODIGO_CLIENTE,B.NOM AS NOMBRE_CLIENTE,B.DOM AS DOMICILIO_CLIENTE,B.LOC AS LOCALIDAD,B.PCI AS PROVINCIA,B.CPO AS CODIGO_POSTAL," + + "C.NET AS NETO," + + "C.NEE AS NETO_EXENTO," + + "C.IRI + C.IRS AS IVA," + + "C.IMI + C.IMI2 + C.IMI3 AS IMPUESTOS_INTERNOS," + + "C.PER AS PERCEPCION_IIBB," + + "C.PER_IVA AS PERCECPION_IVA," + + "C.TOT AS TOTAL " + + "FROM ACOBYPAG A " + + "FULL OUTER JOIN AMAEFACT C ON A.CYV = C.CYV AND A.TIP=C.TIP AND A.TCO=C.TCO AND A.SUC=C.SUC AND A.NCO=C.NCO " + + "INNER JOIN CLIENTES B ON A.COD=B.COD"+ + " ')" + ).raw( + "if OBJECT_ID('[dbo].[VI_ACOBYPAG_VENCIMIENTOS]') is not null "+ + "begin " + + "drop view VI_ACOBYPAG_VENCIMIENTOS "+ + "end " + + "execute(' " + + "CREATE VIEW [VI_ACOBYPAG_VENCIMIENTOS]" + + "AS " + + "SELECT A.*,B.FEP AS FECHA_COMPROBANTE,C.ID_MONEDA AS MONEDA,C.COTIZACION AS COTIZACION," + + "C.NET AS NETO," + + "C.NEE AS NETO_EXENTO," + + "C.IRI + C.IRS AS IVA," + + "C.IMI + C.IMI2 + C.IMI3 AS IMPUESTOS_INTERNOS," + + "C.PER AS PERCEPCION_IIBB," + + "C.PER_IVA AS PERCECPION_IVA," + + "C.TOT AS TOTAL " + + "FROM ACOBYPAG_VENCIMIENTOS A " + + "INNER JOIN ACOBYPAG B ON A.CYV = B.CYV AND A.TIP=B.TIP AND A.TCO=B.TCO AND A.SUC=B.SUC AND A.NCO=B.NCO " + + "INNER JOIN AMAEFACT C ON A.CYV = C.CYV AND A.TIP=C.TIP AND A.TCO=C.TCO AND A.SUC=C.SUC AND A.NCO=C.NCO" + + " ')" + ) + ]) +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema.dropTable('ACOBYPAG_VENCIMIENTOS') + .raw("DROP VIEW [VI_ACOBYPAG_AMAEFACT]") + .raw("DROP VIEW [VI_ACOBYPAG_VENCIMIENTOS]") + ]) +}; diff --git a/migrations/20190220121752_v0.7.5.js b/migrations/20190220121752_v0.7.5.js new file mode 100644 index 0000000..150b953 --- /dev/null +++ b/migrations/20190220121752_v0.7.5.js @@ -0,0 +1,17 @@ + +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.createTable('adetrec_observaciones', function(table) { + table.increments(); + table.string('observacion'); + table.bigInteger('idAdetrec').unsigned(); + }) + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema + .dropTable('adetrec_observaciones') + ]); +}; diff --git a/migrations/20190221092657_v0.7.6.js b/migrations/20190221092657_v0.7.6.js new file mode 100644 index 0000000..a89015e --- /dev/null +++ b/migrations/20190221092657_v0.7.6.js @@ -0,0 +1,24 @@ + +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema + .table('seguimiento', function(table) { + table.bigInteger('idVisita').unsigned(); + }) + .createTable('visita', function(table) { + table.increments(); + table.bigInteger('idCliente').unsigned(); + table.bigInteger('idVisitante').unsigned(); + }) + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema + .table('seguimiento', function(table) { + table.dropColumn('idVisita'); + }) + .dropTable('visita') + ]); +}; diff --git a/migrations/20190225143232_v0.7.7.js b/migrations/20190225143232_v0.7.7.js new file mode 100644 index 0000000..5bcfef9 --- /dev/null +++ b/migrations/20190225143232_v0.7.7.js @@ -0,0 +1,14 @@ + +exports.up = function(knex, Promise) { + return knex.schema + .table('seguimiento', function(table) { + table.dropColumn('idUsuario'); + }); +}; + +exports.down = function(knex, Promise) { + return knex.schema + .table('seguimiento', function(table) { + table.bigInteger('idUsuario').unsigned(); + }); +}; diff --git a/migrations/20190228111345_v0.7.8.js b/migrations/20190228111345_v0.7.8.js new file mode 100644 index 0000000..f36aa94 --- /dev/null +++ b/migrations/20190228111345_v0.7.8.js @@ -0,0 +1,63 @@ +exports.up = function(knex, Promise) { + return knex.schema + .table('articulo_nota_pedido', function(table) { + table.dropColumns( + 'costoUnitario', 'exentoUnitario', 'impuestoInternoUnitario', + 'impuestoInterno1Unitario', 'impuestoInterno2Unitario', 'ivaServicioUnitario', + 'ivaUnitario', 'tasaIva'); + }).table('articulo_nota_pedido', function(table) { + table.decimal('netoUnitario', 14, 4); + table.decimal('costoUnitario', 14, 4); + table.decimal('exentoUnitario', 14, 4); + table.decimal('impuestoInternoUnitario', 14, 4); + table.decimal('impuestoInterno1Unitario', 14, 4); + table.decimal('impuestoInterno2Unitario', 14, 4); + table.decimal('ivaServicioUnitario', 14, 4); + table.decimal('ivaUnitario', 14, 4); + table.decimal('tasaIva', 14, 4); + }).table('articulo_remito', function(table) { + table.dropColumns( + 'costoUnitario', 'exentoUnitario', 'impuestoInternoUnitario', + 'impuestoInterno1Unitario', 'impuestoInterno2Unitario', 'ivaServicioUnitario', + 'ivaUnitario', 'tasaIva'); + }).table('articulo_remito', function(table) { + table.decimal('netoUnitario', 14, 4); + table.decimal('costoUnitario', 14, 4); + table.decimal('exentoUnitario', 14, 4); + table.decimal('impuestoInternoUnitario', 14, 4); + table.decimal('impuestoInterno1Unitario', 14, 4); + table.decimal('impuestoInterno2Unitario', 14, 4); + table.decimal('ivaServicioUnitario', 14, 4); + table.decimal('ivaUnitario', 14, 4); + table.decimal('tasaIva', 14, 4); + }) +}; + +exports.down = function(knex, Promise) { + return knex.schema + .table('articulo_nota_pedido', function(table) { + table.dropColumns('netoUnitario', 'costoUnitario', 'exentoUnitario', + 'impuestoInternoUnitario', 'impuestoInterno1Unitario', 'impuestoInterno2Unitario', + 'ivaServicioUnitario', 'ivaUnitario', 'tasaIva'); + table.decimal('costoUnitario', 12, 2); + table.decimal('exentoUnitario', 12, 2); + table.decimal('impuestoInternoUnitario', 12, 2); + table.decimal('impuestoInterno1Unitario', 12, 2); + table.decimal('impuestoInterno2Unitario', 12, 2); + table.decimal('ivaServicioUnitario', 12, 2); + table.decimal('ivaUnitario', 12, 2); + table.decimal('tasaIva', 12, 2); + }).table('articulo_remito', function(table) { + table.dropColumns('netoUnitario', 'costoUnitario', 'exentoUnitario', + 'impuestoInternoUnitario', 'impuestoInterno1Unitario', 'impuestoInterno2Unitario', + 'ivaServicioUnitario', 'ivaUnitario', 'tasaIva'); + table.decimal('costoUnitario', 12, 2); + table.decimal('exentoUnitario', 12, 2); + table.decimal('impuestoInternoUnitario', 12, 2); + table.decimal('impuestoInterno1Unitario', 12, 2); + table.decimal('impuestoInterno2Unitario', 12, 2); + table.decimal('ivaServicioUnitario', 12, 2); + table.decimal('ivaUnitario', 12, 2); + table.decimal('tasaIva', 12, 2); + }) +}; diff --git a/migrations/20190311170816_v0.8.0.js b/migrations/20190311170816_v0.8.0.js new file mode 100644 index 0000000..dc2a455 --- /dev/null +++ b/migrations/20190311170816_v0.8.0.js @@ -0,0 +1,23 @@ +const md5 = require('md5'); + +exports.up = function(knex, Promise) { + + return knex.schema + .table('APAREMP', function(table) { + + table.string('idEmpresa'); + }).then(function() { + return Promise.all([ + knex('APAREMP').update({ idEmpresa: md5(new Date().getTime())}) + ]); + }); + +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema.table('APAREMP', function(table) { + table.dropColumn('idEmpresa'); + }) + ]); +}; diff --git a/migrations/20190412094131_v0.9.0.js b/migrations/20190412094131_v0.9.0.js new file mode 100644 index 0000000..5b5dbb3 --- /dev/null +++ b/migrations/20190412094131_v0.9.0.js @@ -0,0 +1,18 @@ + +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema + .createTable('remito_punto_descarga', function(table) { + table.increments(); + table.bigInteger('idPuntoDescarga').unsigned(); + table.bigInteger('idRemito').unsigned(); + }) + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema + .dropTable('remito_punto_descarga') + ]); +}; diff --git a/migrations/20190425163004_v0.9.1.js b/migrations/20190425163004_v0.9.1.js new file mode 100644 index 0000000..b939ea8 --- /dev/null +++ b/migrations/20190425163004_v0.9.1.js @@ -0,0 +1,17 @@ + +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema.createTable('parametros', function(table) { + table.increments(); + table.string('modulo'); + table.string('jsonText', [4000]); + table.string('jsonText2', [4000]); + }) + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema.dropTable('parametros') + ]); +}; diff --git a/migrations/20190524103556_v0.10.0.js b/migrations/20190524103556_v0.10.0.js new file mode 100644 index 0000000..8267579 --- /dev/null +++ b/migrations/20190524103556_v0.10.0.js @@ -0,0 +1,37 @@ + +exports.up = function (knex, Promise) { + return Promise.all([ + knex.schema + .table('nota_pedido', function (table) { + table.bigInteger('idListaPrecio').unsigned(); + table.dropColumn('idPrecioCondicion'); + }) + .table('plazo_pago', function (table) { + table.bigInteger('idCliente').unsigned(); + table.dropColumn('idPreciosCondiciones'); + + }) + .table('remito', function (table) { + table.bigInteger('idListaPrecio').unsigned(); + table.dropColumn('idPrecioCondicion'); + }) + ]); +}; + +exports.down = function (knex, Promise) { + return Promise.all([ + knex.schema + .table('nota_pedido', function (table) { + table.dropColumn('idListaPrecio'); + table.bigInteger('idPrecioCondicion').unsigned(); + }) + .table('plazo_pago', function (table) { + table.dropColumn('idCliente'); + table.bigInteger('idPreciosCondiciones').unsigned(); + }) + .table('remito', function (table) { + table.dropColumn('idListaPrecio'); + table.bigInteger('idPrecioCondicion').unsigned(); + }) + ]); +}; diff --git a/migrations/20190611150606_v0.11.0.js b/migrations/20190611150606_v0.11.0.js new file mode 100644 index 0000000..6c46fdb --- /dev/null +++ b/migrations/20190611150606_v0.11.0.js @@ -0,0 +1,18 @@ + +exports.up = function(knex, Promise) { + return Promise.all([ + knex.schema + .table('hoja_ruta', function (table) { + table.bigInteger('abierta').unsigned(); + }) + ]); +}; + +exports.down = function(knex, Promise) { + return Promise.all([ + knex.schema + .table('hoja_ruta', function (table) { + table.dropColumn('abierta'); + }) + ]); +}; -- 1.9.1