Commit 9c007cca2dc08dbe3b6a559c4b1b5509563cf283

Authored by Eric Fernandez
1 parent fa78f894e5
Exists in master

all migrations

Showing 45 changed files with 1296 additions and 1 deletions   Show diff stats
... ... @@ -7,4 +7,3 @@ Pasos a seguir instalación y primera migración:
7 7 - Una vez ejecutado el comando se ha creado el archivo `knexfile.js`, configurar la base de datos deseada.
8 8 - En consola correr el comando
9 9 > knex migrate:latest --env nombreConfiguracion
10   -
migrations/20181123153918_v0.1.js
... ... @@ -0,0 +1,210 @@
  1 +
  2 +exports.up = function(knex, Promise) {
  3 + return Promise.all([
  4 + knex.schema.createTable('nota_pedido', function(table) {
  5 + table.increments();
  6 + table.integer('bomba');
  7 + table.integer('cotizacion');
  8 + table.string('cuitCliente');
  9 + table.string('domicilioStamp');
  10 + table.integer('estado');
  11 + table.dateTime('fechaCarga');
  12 + table.integer('flete');
  13 + table.integer('fob');
  14 + table.decimal('kilometros', 12, 2);
  15 + table.string('nombreCliente');
  16 + table.integer('numeroNotaPedido');
  17 + table.integer('responsabilidadIvaCliente');
  18 + table.integer('sucursal');
  19 + table.decimal('total', 12, 2);
  20 + table.bigInteger('idCliente').unsigned();
  21 + table.bigInteger('idCotizacion').unsigned();
  22 + table.bigInteger('idDomicilio').unsigned();
  23 + table.bigInteger('idPrecioCondicion').unsigned();
  24 + table.bigInteger('idProveedor').unsigned();
  25 + table.bigInteger('idRemito').unsigned();
  26 + table.bigInteger('idVendedor').unsigned();
  27 + }).createTable('precios_condiciones', function(table) {
  28 + table.increments();
  29 + table.boolean('activo');
  30 + table.string('codigo');
  31 + table.string('descripcion');
  32 + table.string('nombre');
  33 + table.date('vigencia');
  34 + table.bigInteger('idListaPrecio').unsigned();
  35 + }).createTable('plazo_pago', function(table) {
  36 + table.increments();
  37 + table.boolean('activo');
  38 + table.integer('dias');
  39 + table.integer('item');
  40 + table.bigInteger('idPreciosCondiciones').unsigned();
  41 + }).createTable('articulo_nota_pedido', function(table) {
  42 + table.increments();
  43 + table.decimal('cantidad', 12, 2);
  44 + table.string('codigo');
  45 + table.boolean('combustible');
  46 + table.decimal('costoUnitario', 12, 2);
  47 + table.string('descripcion');
  48 + table.decimal('exentoUnitario', 12, 2);
  49 + table.boolean('facturado');
  50 + table.decimal('impuestoInternoUnitario', 12, 2);
  51 + table.decimal('impuestoInterno1Unitario', 12, 2);
  52 + table.decimal('impuestoInterno2Unitario', 12, 2);
  53 + table.integer('item');
  54 + table.decimal('ivaUnitario', 12, 2);
  55 + table.decimal('ivaServicioUnitario', 12, 2);
  56 + table.string('nombre');
  57 + table.decimal('precio', 12, 4);
  58 + table.decimal('precioLista', 12, 2);
  59 + table.integer('sector');
  60 + table.integer('rubro');
  61 + table.decimal('tasaIva', 12, 2);
  62 + table.bigInteger('idNotaPedido').unsigned();
  63 + }).createTable('boton', function(table) {
  64 + table.increments();
  65 + table.string('accion');
  66 + table.string('app');
  67 + table.string('clase');
  68 + table.string('texto');
  69 + }).createTable('chofer', function(table) {
  70 + table.increments();
  71 + table.string('dni');
  72 + table.string('nombre');
  73 + table.string('telefono');
  74 + table.bigInteger('idTransportista').unsigned();
  75 + }).createTable('vehiculo', function(table) {
  76 + table.increments();
  77 + table.string('capacidad');
  78 + table.string('cisternado');
  79 + table.string('semi');
  80 + table.string('tractor');
  81 + table.bigInteger('idTransportista').unsigned();
  82 + // TODO: Revisar si en los seeds no inserta por ser nombres de campo demasiado largos.
  83 + // table.string('seguimientoSatelitalUrl');
  84 + // table.string('seguimientoSatelitalUsuario');
  85 + // table.string('seguimientoSatelitalClave');
  86 + }).createTable('nota-pedido-plazo', function(table) {
  87 + table.increments();
  88 + table.integer('dias').unsigned();
  89 + table.bigInteger('idNotaPedido').unsigned();
  90 + }).createTable('seguimiento', function(table) {
  91 + table.increments();
  92 + table.string('actividad');
  93 + table.integer('distancia');
  94 + table.dateTime('fecha');
  95 + table.string('latitud');
  96 + table.string('longitud');
  97 + table.string('observaciones');
  98 + table.integer('orden');
  99 + table.bigInteger('idUsuario').unsigned();
  100 + }).createTable('nota-pedido-estado', function(table) {
  101 + table.increments();
  102 + table.integer('estado');
  103 + table.dateTime('fecha');
  104 + table.bigInteger('idNotaPedido').unsigned();
  105 + table.integer('idVendedor').unsigned();
  106 + }).createTable('configuracion_terminal', function(table) {
  107 + table.increments();
  108 + table.string('terminalKey');
  109 + table.string('valor');
  110 + table.string('variable');
  111 + }).createTable('remito', function(table) {
  112 + table.increments();
  113 + table.boolean('anulado');
  114 + table.integer('asiento');
  115 + table.integer('bomba');
  116 + table.decimal('carga', 12, 2);
  117 + table.string('cuitCliente');
  118 + table.integer('cuentaContable');
  119 + table.integer('cuentaMadre');
  120 + table.decimal('descuento', 12, 2);
  121 + table.integer('destinoVenta');
  122 + table.string('domicilioStamp');
  123 + table.integer('estado');
  124 + table.dateTime('fechaRemito');
  125 + table.integer('flete');
  126 + table.integer('fob');
  127 + table.decimal('importeExento', 12, 2);
  128 + table.decimal('importeImpuestoInterno', 12, 2);
  129 + table.decimal('importeImpuestoInterno1', 12, 2);
  130 + table.decimal('importeImpuestoInterno2', 12, 2);
  131 + table.decimal('importeIva', 12, 2);
  132 + table.decimal('importeIvaServicios', 12, 2);
  133 + table.decimal('importeNeto', 12, 2);
  134 + table.decimal('kilometros', 12, 2);
  135 + table.integer('lugar');
  136 + table.string('nombreCliente');
  137 + table.integer('numeroLiquidoProducto');
  138 + table.integer('numeroNotaPedido');
  139 + table.integer('numeroRemito');
  140 + table.integer('operacionTipo');
  141 + table.decimal('percepcion', 12, 2);
  142 + table.decimal('percepcionIva', 12, 2);
  143 + table.integer('planilla');
  144 + table.integer('sucursal');
  145 + table.decimal('redondeo', 12, 2);
  146 + table.integer('responsabilidadIvaCliente');
  147 + table.decimal('total', 12, 2);
  148 + table.bigInteger('idVendedor').unsigned();
  149 + table.bigInteger('idProveedor').unsigned();
  150 + table.bigInteger('idDomicilio').unsigned();
  151 + table.bigInteger('idCotizacion').unsigned();
  152 + table.bigInteger('idPrecioCondicion').unsigned();
  153 + table.bigInteger('idHojaRuta').unsigned();
  154 + table.bigInteger('idCliente').unsigned();
  155 + table.string('e_hd');
  156 + table.string('c_hd');
  157 + }).createTable('articulo_remito', function(table) {
  158 + table.increments();
  159 + table.decimal('cantidad', 12, 2);
  160 + table.string('codigo');
  161 + table.boolean('combustible');
  162 + table.decimal('costoUnitario', 12, 2);
  163 + table.string('descripcion');
  164 + table.decimal('exentoUnitario', 12, 2);
  165 + table.boolean('facturado');
  166 + table.integer('item');
  167 + table.decimal('impuestoInternoUnitario', 12, 2);
  168 + table.decimal('impuestoInterno1Unitario', 12, 2);
  169 + table.decimal('impuestoInterno2Unitario', 12, 2);
  170 + table.decimal('ivaServicioUnitario', 12, 2);
  171 + table.decimal('ivaUnitario', 12, 2);
  172 + table.string('nombre');
  173 + table.decimal('precio', 12, 4);
  174 + table.decimal('precioLista', 12, 2);
  175 + table.integer('sector');
  176 + table.integer('rubro');
  177 + table.decimal('tasaIva', 12, 2);
  178 + table.bigInteger('idRemito').unsigned();
  179 + }).createTable('hoja_ruta', function(table) {
  180 + table.increments();
  181 + table.dateTime('fechaCreacion');
  182 + table.bigInteger('numeroHojaRuta').unsigned();
  183 + table.integer('sucursal').unsigned();
  184 + table.decimal('tarifaFlete', 12, 2);
  185 + table.bigInteger('idTransportista').unsigned();
  186 + table.bigInteger('idChofer').unsigned();
  187 + table.bigInteger('idVehiculo').unsigned();
  188 + })
  189 + ]);
  190 +};
  191 +
  192 +exports.down = function(knex, Promise) {
  193 + return Promise.all([
  194 + knex.schema
  195 + .dropTable('nota_pedido')
  196 + .dropTable('precios_condiciones')
  197 + .dropTable('plazo_pago')
  198 + .dropTable('articulo_nota_pedido')
  199 + .dropTable('boton')
  200 + .dropTable('chofer')
  201 + .dropTable('vehiculo')
  202 + .dropTable('nota-pedido-plazo')
  203 + .dropTable('seguimiento')
  204 + .dropTable('nota-pedido-estado')
  205 + .dropTable('configuracion_terminal')
  206 + .dropTable('remito')
  207 + .dropTable('articulo_remito')
  208 + .dropTable('hoja_ruta')
  209 + ]);
  210 +};
migrations/20181127121352_v0.1.1.js
... ... @@ -0,0 +1,18 @@
  1 +
  2 +exports.up = function(knex, Promise) {
  3 + return Promise.all([
  4 + knex.schema.table('APAREMP', function(table) {
  5 + table.decimal('latitud', 10, 7);
  6 + table.decimal('longitud', 10, 7);
  7 + })
  8 + ])
  9 +};
  10 +
  11 +exports.down = function(knex, Promise) {
  12 + return Promise.all([
  13 + knex.schema.table('APAREMP', function(table) {
  14 + table.dropColumn('latitud');
  15 + table.dropColumn('longitud');
  16 + })
  17 + ])
  18 +};
migrations/20181129105456_v0.2.js
... ... @@ -0,0 +1,19 @@
  1 +exports.up = function(knex, Promise) {
  2 + return Promise.all([
  3 + knex.schema.table('vehiculo', function(table) {
  4 + table.boolean('desactivado');
  5 + }).alterTable('chofer', function(table) {
  6 + table.boolean('desactivado');
  7 + })
  8 + ]);
  9 +};
  10 +
  11 +exports.down = function(knex, Promise) {
  12 + return Promise.all([
  13 + knex.schema.table('vehiculo', function(table) {
  14 + table.dropColumn('desactivado');
  15 + }).alterTable('chofer', function(table) {
  16 + table.dropColumn('desactivado');
  17 + })
  18 + ]);
  19 +};
migrations/20181130113831_v0.3.js
... ... @@ -0,0 +1,15 @@
  1 +exports.up = function(knex, Promise) {
  2 + return Promise.all([
  3 + knex.schema.createTable('cobrador', function(table) {
  4 + table.increments();
  5 + table.string('nombre');
  6 + table.boolean('desactivado');
  7 + })
  8 + ]);
  9 +};
  10 +
  11 +exports.down = function(knex, Promise) {
  12 + return Promise.all([
  13 + knex.schema.dropTable('cobrador')
  14 + ]);
  15 +};
migrations/20181206105940_v0.1.2.js
... ... @@ -0,0 +1,15 @@
  1 +exports.up = function(knex, Promise) {
  2 + return Promise.all([
  3 + knex.schema.createTable('remito-plazo', function(table) {
  4 + table.increments();
  5 + table.integer('dias').unsigned();
  6 + table.bigInteger('idRemito').unsigned();
  7 + })
  8 + ]);
  9 +};
  10 +
  11 +exports.down = function(knex, Promise) {
  12 + return Promise.all([
  13 + knex.schema.dropTable('remito-plazo')
  14 + ]);
  15 +};
migrations/20181210132759_v0.4.js
... ... @@ -0,0 +1,15 @@
  1 +exports.up = function(knex, Promise) {
  2 + return Promise.all([
  3 + knex.schema.table('seguimiento', function(table) {
  4 + table.integer('sucursal');
  5 + })
  6 + ]);
  7 +};
  8 +
  9 +exports.down = function(knex, Promise) {
  10 + return Promise.all([
  11 + knex.schema.table('seguimiento', function(table) {
  12 + table.dropColumn('sucursal');
  13 + })
  14 + ]);
  15 +};
migrations/20181211152717_0.4.1.js
... ... @@ -0,0 +1,16 @@
  1 +exports.up = function(knex, Promise) {
  2 + return Promise.all([
  3 + knex.schema.table('ARECIBOS', function(table) {
  4 + table.bigInteger('idCobrador').unsigned();
  5 + })
  6 + ]);
  7 +
  8 +};
  9 +
  10 +exports.down = function(knex, Promise) {
  11 + return Promise.all([
  12 + knex.schema.table('ARECIBOS', function(table) {
  13 + table.dropColumn('idCobrador');
  14 + })
  15 + ]);
  16 +};
migrations/20181213153525_0.5.js
... ... @@ -0,0 +1,65 @@
  1 +
  2 +exports.up = function(knex, Promise) {
  3 + return Promise.all([
  4 + knex.schema
  5 + .table('vehiculo', function(table) {
  6 + table.string('codigo');
  7 + table.dropColumn('cisternado');
  8 + })
  9 + .createTable('cisterna', function(table) {
  10 + table.increments();
  11 + table.string('codigo');
  12 + table.decimal('capacidad', 12, 2);
  13 + table.bigInteger('idVehiculo').unsigned();
  14 + table.bigInteger('idUnidadMedida').unsigned();
  15 + table.bigInteger('idCarga').unsigned();
  16 + })
  17 + .createTable('cisterna_carga', function(table) {
  18 + table.increments();
  19 + table.decimal('cantidad', 12, 2);
  20 + table.bigInteger('codigoArticulo').unsigned();
  21 + table.bigInteger('codigoSectorArticulo').unsigned();
  22 + })
  23 + .createTable('cisterna_movimiento', function(table) {
  24 + table.increments();
  25 + table.dateTime('fecha');
  26 + table.decimal('cantidad', 12, 2);
  27 + table.string('metodo');
  28 + table.bigInteger('idCisternaCarga').unsigned();
  29 + })
  30 + .createTable('hoja_ruta_movimiento', function(table) {
  31 + table.increments();
  32 + table.string('reciboDescarga');
  33 + table.bigInteger('idRemito').unsigned();
  34 + table.bigInteger('idCisternaMovimiento').unsigned();
  35 + table.bigInteger('idSeguimiento').unsigned();
  36 + })
  37 + .table('nota_pedido', function(table) {
  38 + table.bigInteger('idSeguimiento').unsigned();
  39 + })
  40 + .table('hoja_ruta', function(table) {
  41 + table.bigInteger('idSeguimiento').unsigned();
  42 + })
  43 + ]);
  44 +};
  45 +
  46 +exports.down = function(knex, Promise) {
  47 + return Promise.all([
  48 + knex.schema
  49 + .table('vehiculo', function(table) {
  50 + table.string('cisternado');
  51 + table.dropColumn('codigo');
  52 + })
  53 + .table('nota_pedido', function(table) {
  54 + table.dropColumn('idSeguimiento');
  55 + })
  56 + .table('hoja_ruta', function(table) {
  57 + table.dropColumn('idSeguimiento');
  58 + })
  59 + .dropTable('cisterna')
  60 + .dropTable('cisterna_carga')
  61 + .dropTable('cisterna_movimiento')
  62 + .dropTable('hoja_ruta_movimiento')
  63 +
  64 + ]);
  65 +};
migrations/20181217131259_v0.6.js
... ... @@ -0,0 +1,24 @@
  1 +exports.up = function(knex, Promise) {
  2 + return Promise.all([
  3 + knex.schema
  4 + .raw("ALTER TABLE ARTICULOS ADD id INT IDENTITY(1,1)")
  5 + .table('cisterna_carga', function(table) {
  6 + table.dropColumn('codigoArticulo');
  7 + table.dropColumn('codigoSectorArticulo');
  8 + table.bigInteger('idProducto').unsigned();
  9 + })
  10 + ]);
  11 +};
  12 +
  13 +exports.down = function(knex, Promise) {
  14 + return Promise.all([
  15 + knex.schema
  16 + .table('ARTICULOS', function(table) {
  17 + table.dropColumn('id');
  18 + }).table('cisterna_carga', function(table) {
  19 + table.dropColumn('idProducto');
  20 + table.bigInteger('codigoArticulo').unsigned();
  21 + table.bigInteger('codigoSectorArticulo').unsigned();
  22 + })
  23 + ]);
  24 +};
migrations/20181217172010_v0.5.1.js
... ... @@ -0,0 +1,15 @@
  1 +exports.up = function(knex, Promise) {
  2 + return Promise.all([
  3 + knex.schema.table('cisterna', function(table) {
  4 + table.boolean('desactivado');
  5 + })
  6 + ])
  7 +};
  8 +
  9 +exports.down = function(knex, Promise) {
  10 + return Promise.all([
  11 + knex.schema.table('cisterna', function(table) {
  12 + table.dropColumn('desactivado');
  13 + })
  14 + ])
  15 +};
migrations/20181218155954_0.6.1.js
... ... @@ -0,0 +1,19 @@
  1 +exports.up = function(knex, Promise) {
  2 + return Promise.all([
  3 + knex.schema
  4 + .raw("ALTER TABLE ARECIBOS ADD id INT IDENTITY(1,1)")
  5 + .table('ARECIBOS', function(table) {
  6 + table.bigInteger('idSeguimiento').unsigned();
  7 + })
  8 + ]);
  9 +};
  10 +
  11 +exports.down = function(knex, Promise) {
  12 + return Promise.all([
  13 + knex.schema
  14 + .table('ARECIBOS', function(table) {
  15 + table.dropColumn('id');
  16 + table.dropColumn('idSeguimiento');
  17 + })
  18 + ]);
  19 +};
migrations/20181221125659_0.6.2.js
... ... @@ -0,0 +1,16 @@
  1 +
  2 +exports.up = function(knex, Promise) {
  3 + return Promise.all([
  4 + knex.schema.table('precios_condiciones', function(table) {
  5 + table.dropColumn('idListaPrecio')
  6 + }).raw("ALTER TABLE precios_condiciones ADD idListaPrecio char(4)")
  7 + ])
  8 +};
  9 +
  10 +exports.down = function(knex, Promise) {
  11 + return Promise.all([
  12 + knex.schema.table('precios_condiciones', function(table) {
  13 + table.dropColumn('idListaPrecio')
  14 + })
  15 + ]);
  16 +};
migrations/20181221173513_v0.6.3.js
... ... @@ -0,0 +1,15 @@
  1 +exports.up = function(knex, Promise) {
  2 + return Promise.all([
  3 + knex.schema.table('articulo_nota_pedido', function(table) {
  4 + table.bigint('idArticulo').unsigned();
  5 + })
  6 + ])
  7 +};
  8 +
  9 +exports.down = function(knex, Promise) {
  10 + return Promise.all([
  11 + knex.schema.table('articulo_nota_pedido', function(table) {
  12 + table.dropColumn('idArticulo');
  13 + })
  14 + ])
  15 +};
migrations/20181226120323_v0.6.4.js
... ... @@ -0,0 +1,15 @@
  1 +exports.up = function(knex, Promise) {
  2 + return Promise.all([
  3 + knex.schema.table('articulo_remito', function(table) {
  4 + table.bigint('idArticulo').unsigned();
  5 + })
  6 + ])
  7 +};
  8 +
  9 +exports.down = function(knex, Promise) {
  10 + return Promise.all([
  11 + knex.schema.table('articulo_remito', function(table) {
  12 + table.dropColumn('idArticulo');
  13 + })
  14 + ])
  15 +};
migrations/20181227171744_v0.6.5.js
... ... @@ -0,0 +1,25 @@
  1 +exports.up = function(knex, Promise) {
  2 + return Promise.all([
  3 + knex.schema
  4 + .table('cisterna_movimiento', function(table) {
  5 + table.bigint('idRemito').unsigned();
  6 + }).table('remito', function(table) {
  7 + table.bigint('idUsuarioProceso').unsigned();
  8 + }).table('vehiculo', function(table) {
  9 + table.bigint('idUsuarioProceso').unsigned();
  10 + })
  11 + ])
  12 +};
  13 +
  14 +exports.down = function(knex, Promise) {
  15 + return Promise.all([
  16 + knex.schema
  17 + .table('cisterna_movimiento', function(table) {
  18 + table.dropColumn('idRemito');
  19 + }).table('remito', function(table) {
  20 + table.dropColumn('idUsuarioProceso');
  21 + }).table('vehiculo', function(table) {
  22 + table.dropColumn('idUsuarioProceso');
  23 + })
  24 + ])
  25 +};
migrations/20181231114424_v0.6.6.js
... ... @@ -0,0 +1,36 @@
  1 +
  2 +exports.up = function(knex, Promise) {
  3 + return Promise.all([
  4 + knex.schema
  5 + .createTable('a_punto_descarga', function(table) {
  6 + table.increments();
  7 + table.bigInteger('id_cliente');
  8 + table.bigInteger('id_da_config_0');
  9 + table.string('descripcion');
  10 + table.string('latitud');
  11 + table.string('longitud');
  12 + table.boolean('desactivado');
  13 + })
  14 + .table('CLIENTES', function(table) {
  15 + table.boolean('ES_PROS');
  16 + })
  17 + .createTable('nota_pedido_punto_descarga', function(table) {
  18 + table.increments();
  19 + table.bigInteger('idPuntoDescarga').unsigned();
  20 + table.bigInteger('idNotaPedido').unsigned();
  21 + table.bigInteger('idProducto').unsigned();
  22 + table.decimal('cantidad', 12, 2);
  23 + })
  24 + ]);
  25 +};
  26 +
  27 +exports.down = function(knex, Promise) {
  28 + return Promise.all([
  29 + knex.schema
  30 + .dropTable('a_punto_descarga')
  31 + .table('CLIENTES', function(table) {
  32 + table.dropColumn('ES_PROS');
  33 + })
  34 + .dropTable('nota_pedido_punto_descarga')
  35 + ]);
  36 +};
migrations/20190102160859_v0.6.7.js
... ... @@ -0,0 +1,15 @@
  1 +exports.up = function(knex, Promise) {
  2 + return Promise.all([
  3 + knex.schema.table('cisterna_movimiento', function(table) {
  4 + table.boolean('anulado');
  5 + })
  6 + ])
  7 +};
  8 +
  9 +exports.down = function(knex, Promise) {
  10 + return Promise.all([
  11 + knex.schema.table('cisterna_movimiento', function(table) {
  12 + table.dropColumn('anulado');
  13 + })
  14 + ])
  15 +};
migrations/20190107163621_v0.6.8.js
... ... @@ -0,0 +1,16 @@
  1 +
  2 +exports.up = function(knex, Promise) {
  3 + return Promise.all([
  4 + knex.schema.table('VENDEDORES', function(table) {
  5 + table.boolean('ES_COBRADOR');
  6 + })
  7 + ]);
  8 +};
  9 +
  10 +exports.down = function(knex, Promise) {
  11 + return Promise.all([
  12 + knex.schema.table('VENDEDORES', function(table) {
  13 + table.dropColumn('ES_COBRADOR');
  14 + })
  15 + ]);
  16 +};
migrations/20190108114746_v0.6.9.js
... ... @@ -0,0 +1,26 @@
  1 +exports.up = function(knex, Promise) {
  2 + return Promise.all([
  3 + knex.schema
  4 + .table('cisterna', function(table) {
  5 + table.dropColumn('idCarga');
  6 + })
  7 + .table('cisterna_carga', function(table) {
  8 + table.bigInteger('idCisterna').unsigned();
  9 + table.date('fechaReparto');
  10 + })
  11 + ])
  12 +};
  13 +
  14 +exports.down = function(knex, Promise) {
  15 + return Promise.all([
  16 + knex.schema
  17 + .table('cisterna', function(table) {
  18 + table.bigInteger('idCarga');
  19 + })
  20 + .table('cisterna_carga', function(table) {
  21 + table
  22 + .dropColumn('idCisterna')
  23 + .dropColumn('fechaReparto');
  24 + })
  25 + ])
  26 +};
migrations/20190109123406_v0.6.10.js
... ... @@ -0,0 +1,16 @@
  1 +
  2 +exports.up = function(knex, Promise) {
  3 + return Promise.all([
  4 + knex.schema.table('VENDEDORES', function(table) {
  5 + table.boolean('desactivado');
  6 + })
  7 + ]);
  8 +};
  9 +
  10 +exports.down = function(knex, Promise) {
  11 + return Promise.all([
  12 + knex.schema.table('VENDEDORES', function(table) {
  13 + table.dropColumn('desactivado');
  14 + })
  15 + ]);
  16 +};
migrations/20190109123752_v0.6.11.js
... ... @@ -0,0 +1,28 @@
  1 +
  2 +exports.up = function(knex, Promise) {
  3 + return Promise.all([
  4 + knex.schema.createTable('login', function(table) {
  5 + table.increments();
  6 + table.string('username');
  7 + table.string('password');
  8 + table.boolean('activo');
  9 + }).table('VENDEDORES', function(table) {
  10 + table.bigInteger('idLogin').unsigned();
  11 + }).table('chofer', function(table) {
  12 + table.bigInteger('idLogin').unsigned();
  13 + })
  14 + ]);
  15 +};
  16 +
  17 +exports.down = function(knex, Promise) {
  18 + return Promise.all([
  19 + knex.schema
  20 + .dropTable('login')
  21 + .table('vendedores', function(table) {
  22 + table.dropColumn('idLogin');
  23 + })
  24 + .table('chofer', function(table) {
  25 + table.dropColumn('idLogin');
  26 + })
  27 + ]);
  28 +};
migrations/20190110100715_v0.6.12.js
... ... @@ -0,0 +1,24 @@
  1 +exports.up = function(knex, Promise) {
  2 + return Promise.all([
  3 + knex.schema
  4 + .table('vehiculo', function(table) {
  5 + table.dropColumn('idUsuarioProceso');
  6 + })
  7 + .table('cisterna_carga', function(table) {
  8 + table.bigInteger('idUsuarioProceso');
  9 + table.boolean('confirmado');
  10 + })
  11 + ])
  12 +};
  13 +
  14 +exports.down = function(knex, Promise) {
  15 + return Promise.all([
  16 + knex.schema
  17 + .table('vehiculo', function(table) {
  18 + table.bigint('idUsuarioProceso').unsigned();
  19 + })
  20 + .table('cisterna_carga', function(table) {
  21 + table.dropColumns('idUsuarioProceso', 'confirmado');
  22 + })
  23 + ])
  24 +};
migrations/20190110152626_v0.6.13.js
... ... @@ -0,0 +1,16 @@
  1 +exports.up = function(knex, Promise) {
  2 + return Promise.all([
  3 + knex.schema.table('login', function(table) {
  4 + table.dateTime('ultimoLogin');
  5 + table.string('token');
  6 + })
  7 + ])
  8 +};
  9 +
  10 +exports.down = function(knex, Promise) {
  11 + return Promise.all([
  12 + knex.schema.table('login', function(table) {
  13 + table.dropColumns('ultimoLogin', 'token');
  14 + })
  15 + ]);
  16 +};
migrations/20190114160629_v0.6.14.js
... ... @@ -0,0 +1,19 @@
  1 +
  2 +exports.up = function(knex, Promise) {
  3 + return Promise.all([
  4 + knex.schema.table('hoja_ruta', function(table) {
  5 + //0=disponible 1=asignado 2=terminado
  6 + table.integer('estado').unsigned();
  7 + table.date('fechaReparto');
  8 + })
  9 + ]);
  10 +};
  11 +
  12 +exports.down = function(knex, Promise) {
  13 + return Promise.all([
  14 + knex.schema.table('hoja_ruta', function(table) {
  15 + table.dropColumn('estado');
  16 + table.dropColumn('fechaReparto');
  17 + })
  18 + ]);
  19 +};
migrations/20190118161051_v0.6.15.js
... ... @@ -0,0 +1,17 @@
  1 +
  2 +exports.up = function(knex, Promise) {
  3 + return Promise.all([
  4 + knex.schema.createTable('tipo_documento', function(table) {
  5 + table.integer('id').unsigned().primary();
  6 + table.string('descripcion');
  7 + table.string('orden');
  8 + table.boolean('activo');
  9 + })
  10 + ])
  11 +};
  12 +
  13 +exports.down = function(knex, Promise) {
  14 + return Promise.all([
  15 + knex.schema.dropTable('tipo_documento')
  16 + ]);
  17 +};
migrations/20190121125737_v0.6.16.js
... ... @@ -0,0 +1,22 @@
  1 +exports.up = function(knex, Promise) {
  2 + return Promise.all([
  3 + knex.schema
  4 + .table('articulo_remito', function(table) {
  5 + table.integer('cantidadDescargada');
  6 + }).table('remito', function(table) {
  7 + table.boolean('rechazado');
  8 + table.string('motivoRechazo');
  9 + })
  10 + ])
  11 +};
  12 +
  13 +exports.down = function(knex, Promise) {
  14 + return Promise.all([
  15 + knex.schema
  16 + .table('articulo_remito', function(table) {
  17 + table.dropColumn('cantidadDescargada');
  18 + }).table('remito', function(table) {
  19 + table.dropColumns('rechazado', 'motivoRechazo');
  20 + })
  21 + ])
  22 +};
migrations/20190122165422_v0.6.17.js
... ... @@ -0,0 +1,35 @@
  1 +exports.up = function(knex, Promise) {
  2 + return Promise.all([
  3 + knex.schema.table('hoja_ruta', function(table) {
  4 + table.decimal('kmInicialVehiculo', 18, 4);
  5 + table.decimal('kmFinalVehiculo', 18, 4)
  6 + table.decimal('aforadorInicialVehiculo', 18, 4);
  7 + table.decimal('aforadorFinalVehiculo', 18, 4)
  8 + table.decimal('cantidadDescargaPorGravedad', 18, 4);
  9 + table.decimal('litrosDescargadosPorGravedad', 18, 4);
  10 + table.decimal('litrosCombustibleParaMovilidad', 18, 4);
  11 + table.string('precintoBocaUno');
  12 + table.string('precintoBocaDos');
  13 + table.string('precintoBocaTres');
  14 + })
  15 + ]);
  16 +};
  17 +
  18 +exports.down = function(knex, Promise) {
  19 + return Promise.all([
  20 + knex.schema.table('hoja_ruta', function(table) {
  21 + table.dropColumns(
  22 + 'kmInicialVehiculo',
  23 + 'kmFinalVehiculo',
  24 + 'aforadorInicialVehiculo',
  25 + 'aforadorFinalVehiculo',
  26 + 'cantidadDescargaPorGravedad',
  27 + 'litrosDescargadosPorGravedad',
  28 + 'litrosCombustibleParaMovilidad',
  29 + 'precintoBocaUno',
  30 + 'precintoBocaDos',
  31 + 'precintoBocaTres'
  32 + );
  33 + })
  34 + ]);
  35 +};
migrations/20190125093429_v0.6.18.js
... ... @@ -0,0 +1,16 @@
  1 +
  2 +exports.up = function(knex, Promise) {
  3 + return Promise.all([
  4 + knex.schema.table('chofer', function(table) {
  5 + table.bigInteger('idTipoDocumento').unsigned();
  6 + })
  7 + ]);
  8 +};
  9 +
  10 +exports.down = function(knex, Promise) {
  11 + return Promise.all([
  12 + knex.schema.table('chofer', function(table) {
  13 + table.dropColumn('idTipoDocumento');
  14 + })
  15 + ]);
  16 +};
migrations/20190125102735_v0.6.19.js
... ... @@ -0,0 +1,26 @@
  1 +
  2 +exports.up = function(knex, Promise) {
  3 + return Promise.all([
  4 + knex.schema
  5 + .table('VENDEDORES', function(table) {
  6 + //Puede ser 1=vendedor, 2=cobrador, 3=ambos
  7 + table.integer('rol');
  8 + table.decimal('comisionCobrador', 12, 2);
  9 + })
  10 + .table('CLIENTES', function(table) {
  11 + table.bigInteger('idCobrador').unsigned();
  12 + })
  13 + ]);
  14 +};
  15 +
  16 +exports.down = function(knex, Promise) {
  17 + return Promise.all([
  18 + knex.schema
  19 + .table('VENDEDORES', function(table) {
  20 + table.dropColumns('rol', 'comisionCobrador');
  21 + })
  22 + .table('CLIENTES', function(table) {
  23 + table.dropColumn('idCobrador');
  24 + })
  25 + ]);
  26 +};
migrations/20190131161852_v0.6.20.js
... ... @@ -0,0 +1,18 @@
  1 +exports.up = function(knex, Promise) {
  2 + return Promise.all([
  3 + knex.schema
  4 + .raw("ALTER TABLE ADETREC ADD id INT IDENTITY(1,1)")
  5 + .table('ADETREC', function(table) {
  6 + table.bigInteger('idArecibos');
  7 + })
  8 + ]);
  9 +};
  10 +
  11 +exports.down = function(knex, Promise) {
  12 + return Promise.all([
  13 + knex.schema
  14 + .table('ADETREC', function(table) {
  15 + table.dropColumns('id', 'idArecibos');
  16 + })
  17 + ]);
  18 +};
migrations/20190207113109_v0.7.0.js
... ... @@ -0,0 +1,11 @@
  1 +exports.up = function(knex, Promise) {
  2 + return Promise.all([
  3 + knex.schema.raw('UPDATE VENDEDORES SET desactivado = 0, rol = 1')
  4 + ]);
  5 +};
  6 +
  7 +exports.down = function(knex, Promise) {
  8 + return Promise.all([
  9 + knex.schema.raw('UPDATE VENDEDORES SET desactivado = null, rol = null')
  10 + ]);
  11 +};
migrations/20190208131322_0.7.1.js
... ... @@ -0,0 +1,39 @@
  1 +exports.up = function(knex, Promise) {
  2 + return knex.schema.table('AVENDCLI', function(table) {
  3 + table.string('domicilio');
  4 + table.bigInteger('idLocalidad').unsigned();
  5 + table.bigInteger('idProvincia').unsigned();
  6 + table.integer('codigoPostal').unsigned();
  7 + table.string('telefono');
  8 + table.integer('dni');
  9 + table.boolean('desactivado').notNullable().defaultTo(0);
  10 + table.tinyint('turno').notNullable().defaultTo(0);
  11 + //Puede ser 1=vendedor, 2=cobrador, 3=ambos
  12 + table.integer('rol').notNullable().defaultTo(1);
  13 + table.bigInteger('idLogin').unsigned();
  14 + table.decimal('comisionVendedor', 12, 2).notNullable().defaultTo(0);
  15 + table.decimal('comisionCobrador', 12, 2).notNullable().defaultTo(0);
  16 + }).raw("ALTER TABLE AVENDCLI ADD id INT IDENTITY(1,1)")
  17 +};
  18 +
  19 +exports.down = function(knex, Promise) {
  20 + // PARA HACER FUNCIONAR ESTE ROLLBACK HAY QUE BORRAR MANUALMENTE LAS CONSTRAINS QUE SE
  21 + // CREAN PARA SER VALORES POR DEFECTO
  22 + return knex.schema.table('AVENDCLI', function(table) {
  23 + table.dropColumns(
  24 + 'id',
  25 + 'domicilio',
  26 + 'idLocalidad',
  27 + 'idProvincia',
  28 + 'codigoPostal',
  29 + 'telefono',
  30 + 'dni',
  31 + 'idLogin',
  32 + 'desactivado',
  33 + 'turno',
  34 + 'rol',
  35 + 'comisionVendedor',
  36 + 'comisionCobrador'
  37 + );
  38 + })
  39 +};
migrations/20190212103514_v0.7.2.js
... ... @@ -0,0 +1,17 @@
  1 +
  2 +exports.up = function(knex, Promise) {
  3 + return Promise.all([
  4 + knex.schema.table('seguimiento', function(table) {
  5 + //KM RECORRIDOS DESDE EL PUNTO ANTERIOR O DESDE LA EMPRESA
  6 + table.decimal('kmRecorridos', 18, 4);
  7 + })
  8 + ]);
  9 +};
  10 +
  11 +exports.down = function(knex, Promise) {
  12 + return Promise.all([
  13 + knex.schema.table('seguimiento', function(table) {
  14 + table.dropColumn('kmRecorridos');
  15 + })
  16 + ]);
  17 +};
migrations/20190215123700_v0.7.3.js
... ... @@ -0,0 +1,24 @@
  1 +
  2 +exports.up = function(knex, Promise) {
  3 + return Promise.all([
  4 + knex.schema
  5 + .table('nota_pedido', function(table) {
  6 + table.string('observaciones');
  7 + })
  8 + .table('remito', function(table) {
  9 + table.string('observaciones');
  10 + })
  11 + ]);
  12 +};
  13 +
  14 +exports.down = function(knex, Promise) {
  15 + return Promise.all([
  16 + knex.schema
  17 + .table('nota_pedido', function(table) {
  18 + table.dropColumn('observaciones');
  19 + })
  20 + .table('remito', function(table) {
  21 + table.dropColumn('observaciones');
  22 + })
  23 + ]);
  24 +};
migrations/20190220100315_v0.7.4.js
... ... @@ -0,0 +1,142 @@
  1 +exports.up = function(knex, Promise) {
  2 + return Promise.all([
  3 + knex.schema.raw(
  4 + "if not exists (SELECT * FROM dbo.sysobjects where id = object_id("+
  5 + "N'dbo.[ACOBYPAG_VENCIMIENTOS]') and OBJECTPROPERTY(id, N'IsTable') = 1) begin "+
  6 + "CREATE TABLE ACOBYPAG_VENCIMIENTOS(" +
  7 + "[CYV] [char](1) NOT NULL," +
  8 + "[COD] [int] NOT NULL," +
  9 + "[FEP] [smalldatetime] NOT NULL," +
  10 + "[TIP] [char](1) NOT NULL," +
  11 + "[TCO] [char](2) NOT NULL," +
  12 + "[SUC] [int] NOT NULL," +
  13 + "[NCO] [bigint] NOT NULL," +
  14 + "[NCU] [bigint] NOT NULL," +
  15 + "[IPA] [money] NOT NULL," +
  16 + "[SAL] [money] NOT NULL," +
  17 + "[TCA] [money] NOT NULL," +
  18 + "[ZONA] [int] NOT NULL," +
  19 + "[FPA] [char](1) NOT NULL," +
  20 + "[REC] [bigint] NOT NULL," +
  21 + "[REP] [bigint] NOT NULL," +
  22 + "[FER] [smalldatetime] NULL," +
  23 + "[REM] [bigint] NOT NULL," +
  24 + "[FRE] [smalldatetime] NULL," +
  25 + "[PRO] [char](1) NOT NULL," +
  26 + "[FEV] [datetime] NULL," +
  27 + "[ANU] [char](1) NOT NULL," +
  28 + "[CCU] [int] NOT NULL," +
  29 + "[UCU] [int] NOT NULL," +
  30 + "[PLA] [int] NOT NULL," +
  31 + "[LUG] [int] NOT NULL," +
  32 + "[PFA] [char](1) NOT NULL," +
  33 + "[RES] [int] NOT NULL," +
  34 + "[LEG] [varchar](15) NOT NULL," +
  35 + "[CTA] [int] NOT NULL," +
  36 + "[FAR] [bit] NOT NULL," +
  37 + "[HOS] [varchar](1) NOT NULL," +
  38 + "[E_HD] [varchar](8) NOT NULL," +
  39 + "[C_HD] [varchar](1) NOT NULL," +
  40 + "[DIC_SEL] [int] NOT NULL," +
  41 + "[SALDO_CALC] [money] NOT NULL," +
  42 + "[IDLP] [varchar](1) NOT NULL," +
  43 + "[ES_CANJE] [bit] NOT NULL," +
  44 + "[CAMBIO_APLICADO] [varchar](50) NOT NULL," +
  45 + "[TIPO_CANJE] [bit] NOT NULL," +
  46 + "[ORD_COM] [int] NOT NULL," +
  47 + "[NATHB] [varchar](1) NOT NULL," +
  48 + "CONSTRAINT [PK_ACOBYPAG_VENCIMIENTOS] PRIMARY KEY CLUSTERED" +
  49 + "(" +
  50 + "[CYV] ASC," +
  51 + "[COD] ASC," +
  52 + "[FEP] ASC," +
  53 + "[TIP] ASC," +
  54 + "[TCO] ASC," +
  55 + "[SUC] ASC," +
  56 + "[NCO] ASC," +
  57 + "[NCU] ASC" +
  58 + ")WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]" +
  59 + ") ON [PRIMARY]" +
  60 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_IPA] DEFAULT ((0)) FOR [IPA]" +
  61 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_SAL] DEFAULT ((0)) FOR [SAL]" +
  62 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_TCA] DEFAULT ((1)) FOR [TCA]" +
  63 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_ZONA] DEFAULT (' ') FOR [ZONA]" +
  64 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_FPA] DEFAULT ((1)) FOR [FPA]" +
  65 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_REC] DEFAULT ((0)) FOR [REC]" +
  66 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_REP] DEFAULT ((0)) FOR [REP]" +
  67 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_REM] DEFAULT ((0)) FOR [REM]" +
  68 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_PRO] DEFAULT ('N') FOR [PRO]" +
  69 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_ANU] DEFAULT (' ') FOR [ANU]" +
  70 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_CCU] DEFAULT ((0)) FOR [CCU]" +
  71 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_UCU] DEFAULT ((0)) FOR [UCU]" +
  72 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_PLA] DEFAULT ((0)) FOR [PLA]" +
  73 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_LUG] DEFAULT ((0)) FOR [LUG]" +
  74 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_PFA] DEFAULT ('N') FOR [PFA]" +
  75 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_RES] DEFAULT ((0)) FOR [RES]" +
  76 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_LEG] DEFAULT ('') FOR [LEG]" +
  77 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_CTA] DEFAULT ((0)) FOR [CTA]" +
  78 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF_ACOBYPAG_VENCIMIENTOS_FAR] DEFAULT ((0)) FOR [FAR]" +
  79 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF__ACOBYPAG_VENCIMIENTOS__HOS__383BDA07] DEFAULT ('') FOR [HOS]" +
  80 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF__ACOBYPAG_VENCIMIENTOS__E_HD__50D27DA7] DEFAULT ('') FOR [E_HD]" +
  81 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD CONSTRAINT [DF__ACOBYPAG_VENCIMIENTOS__C_HD__51C6A1E0] DEFAULT ('') FOR [C_HD]" +
  82 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD DEFAULT ((0)) FOR [DIC_SEL]" +
  83 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD DEFAULT ((0)) FOR [SALDO_CALC]" +
  84 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD DEFAULT ('') FOR [IDLP]" +
  85 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD DEFAULT ((0)) FOR [ES_CANJE]" +
  86 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD DEFAULT ('') FOR [CAMBIO_APLICADO]" +
  87 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD DEFAULT ((0)) FOR [TIPO_CANJE]" +
  88 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD DEFAULT ((0)) FOR [ORD_COM]" +
  89 + "ALTER TABLE ACOBYPAG_VENCIMIENTOS ADD DEFAULT ('') FOR [NATHB]" +
  90 + " end"
  91 + ).raw(
  92 + "if OBJECT_ID('[dbo].[VI_ACOBYPAG_AMAEFACT]') is not null "+
  93 + "begin " +
  94 + "drop view VI_ACOBYPAG_AMAEFACT "+
  95 + "end " +
  96 + "execute(' " +
  97 + "CREATE VIEW [VI_ACOBYPAG_AMAEFACT]" +
  98 + "AS " +
  99 + "SELECT A.*, A.FEP as FECHA_COMPROBANTE, C.ID_MONEDA AS MONEDA,C.COTIZACION AS COTIZACION," +
  100 + "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," +
  101 + "C.NET AS NETO," +
  102 + "C.NEE AS NETO_EXENTO," +
  103 + "C.IRI + C.IRS AS IVA," +
  104 + "C.IMI + C.IMI2 + C.IMI3 AS IMPUESTOS_INTERNOS," +
  105 + "C.PER AS PERCEPCION_IIBB," +
  106 + "C.PER_IVA AS PERCECPION_IVA," +
  107 + "C.TOT AS TOTAL " +
  108 + "FROM ACOBYPAG A " +
  109 + "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 " +
  110 + "INNER JOIN CLIENTES B ON A.COD=B.COD"+
  111 + " ')"
  112 + ).raw(
  113 + "if OBJECT_ID('[dbo].[VI_ACOBYPAG_VENCIMIENTOS]') is not null "+
  114 + "begin " +
  115 + "drop view VI_ACOBYPAG_VENCIMIENTOS "+
  116 + "end " +
  117 + "execute(' " +
  118 + "CREATE VIEW [VI_ACOBYPAG_VENCIMIENTOS]" +
  119 + "AS " +
  120 + "SELECT A.*,B.FEP AS FECHA_COMPROBANTE,C.ID_MONEDA AS MONEDA,C.COTIZACION AS COTIZACION," +
  121 + "C.NET AS NETO," +
  122 + "C.NEE AS NETO_EXENTO," +
  123 + "C.IRI + C.IRS AS IVA," +
  124 + "C.IMI + C.IMI2 + C.IMI3 AS IMPUESTOS_INTERNOS," +
  125 + "C.PER AS PERCEPCION_IIBB," +
  126 + "C.PER_IVA AS PERCECPION_IVA," +
  127 + "C.TOT AS TOTAL " +
  128 + "FROM ACOBYPAG_VENCIMIENTOS A " +
  129 + "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 " +
  130 + "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" +
  131 + " ')"
  132 + )
  133 + ])
  134 +};
  135 +
  136 +exports.down = function(knex, Promise) {
  137 + return Promise.all([
  138 + knex.schema.dropTable('ACOBYPAG_VENCIMIENTOS')
  139 + .raw("DROP VIEW [VI_ACOBYPAG_AMAEFACT]")
  140 + .raw("DROP VIEW [VI_ACOBYPAG_VENCIMIENTOS]")
  141 + ])
  142 +};
migrations/20190220121752_v0.7.5.js
... ... @@ -0,0 +1,17 @@
  1 +
  2 +exports.up = function(knex, Promise) {
  3 + return Promise.all([
  4 + knex.schema.createTable('adetrec_observaciones', function(table) {
  5 + table.increments();
  6 + table.string('observacion');
  7 + table.bigInteger('idAdetrec').unsigned();
  8 + })
  9 + ]);
  10 +};
  11 +
  12 +exports.down = function(knex, Promise) {
  13 + return Promise.all([
  14 + knex.schema
  15 + .dropTable('adetrec_observaciones')
  16 + ]);
  17 +};
migrations/20190221092657_v0.7.6.js
... ... @@ -0,0 +1,24 @@
  1 +
  2 +exports.up = function(knex, Promise) {
  3 + return Promise.all([
  4 + knex.schema
  5 + .table('seguimiento', function(table) {
  6 + table.bigInteger('idVisita').unsigned();
  7 + })
  8 + .createTable('visita', function(table) {
  9 + table.increments();
  10 + table.bigInteger('idCliente').unsigned();
  11 + table.bigInteger('idVisitante').unsigned();
  12 + })
  13 + ]);
  14 +};
  15 +
  16 +exports.down = function(knex, Promise) {
  17 + return Promise.all([
  18 + knex.schema
  19 + .table('seguimiento', function(table) {
  20 + table.dropColumn('idVisita');
  21 + })
  22 + .dropTable('visita')
  23 + ]);
  24 +};
migrations/20190225143232_v0.7.7.js
... ... @@ -0,0 +1,14 @@
  1 +
  2 +exports.up = function(knex, Promise) {
  3 + return knex.schema
  4 + .table('seguimiento', function(table) {
  5 + table.dropColumn('idUsuario');
  6 + });
  7 +};
  8 +
  9 +exports.down = function(knex, Promise) {
  10 + return knex.schema
  11 + .table('seguimiento', function(table) {
  12 + table.bigInteger('idUsuario').unsigned();
  13 + });
  14 +};
migrations/20190228111345_v0.7.8.js
... ... @@ -0,0 +1,63 @@
  1 +exports.up = function(knex, Promise) {
  2 + return knex.schema
  3 + .table('articulo_nota_pedido', function(table) {
  4 + table.dropColumns(
  5 + 'costoUnitario', 'exentoUnitario', 'impuestoInternoUnitario',
  6 + 'impuestoInterno1Unitario', 'impuestoInterno2Unitario', 'ivaServicioUnitario',
  7 + 'ivaUnitario', 'tasaIva');
  8 + }).table('articulo_nota_pedido', function(table) {
  9 + table.decimal('netoUnitario', 14, 4);
  10 + table.decimal('costoUnitario', 14, 4);
  11 + table.decimal('exentoUnitario', 14, 4);
  12 + table.decimal('impuestoInternoUnitario', 14, 4);
  13 + table.decimal('impuestoInterno1Unitario', 14, 4);
  14 + table.decimal('impuestoInterno2Unitario', 14, 4);
  15 + table.decimal('ivaServicioUnitario', 14, 4);
  16 + table.decimal('ivaUnitario', 14, 4);
  17 + table.decimal('tasaIva', 14, 4);
  18 + }).table('articulo_remito', function(table) {
  19 + table.dropColumns(
  20 + 'costoUnitario', 'exentoUnitario', 'impuestoInternoUnitario',
  21 + 'impuestoInterno1Unitario', 'impuestoInterno2Unitario', 'ivaServicioUnitario',
  22 + 'ivaUnitario', 'tasaIva');
  23 + }).table('articulo_remito', function(table) {
  24 + table.decimal('netoUnitario', 14, 4);
  25 + table.decimal('costoUnitario', 14, 4);
  26 + table.decimal('exentoUnitario', 14, 4);
  27 + table.decimal('impuestoInternoUnitario', 14, 4);
  28 + table.decimal('impuestoInterno1Unitario', 14, 4);
  29 + table.decimal('impuestoInterno2Unitario', 14, 4);
  30 + table.decimal('ivaServicioUnitario', 14, 4);
  31 + table.decimal('ivaUnitario', 14, 4);
  32 + table.decimal('tasaIva', 14, 4);
  33 + })
  34 +};
  35 +
  36 +exports.down = function(knex, Promise) {
  37 + return knex.schema
  38 + .table('articulo_nota_pedido', function(table) {
  39 + table.dropColumns('netoUnitario', 'costoUnitario', 'exentoUnitario',
  40 + 'impuestoInternoUnitario', 'impuestoInterno1Unitario', 'impuestoInterno2Unitario',
  41 + 'ivaServicioUnitario', 'ivaUnitario', 'tasaIva');
  42 + table.decimal('costoUnitario', 12, 2);
  43 + table.decimal('exentoUnitario', 12, 2);
  44 + table.decimal('impuestoInternoUnitario', 12, 2);
  45 + table.decimal('impuestoInterno1Unitario', 12, 2);
  46 + table.decimal('impuestoInterno2Unitario', 12, 2);
  47 + table.decimal('ivaServicioUnitario', 12, 2);
  48 + table.decimal('ivaUnitario', 12, 2);
  49 + table.decimal('tasaIva', 12, 2);
  50 + }).table('articulo_remito', function(table) {
  51 + table.dropColumns('netoUnitario', 'costoUnitario', 'exentoUnitario',
  52 + 'impuestoInternoUnitario', 'impuestoInterno1Unitario', 'impuestoInterno2Unitario',
  53 + 'ivaServicioUnitario', 'ivaUnitario', 'tasaIva');
  54 + table.decimal('costoUnitario', 12, 2);
  55 + table.decimal('exentoUnitario', 12, 2);
  56 + table.decimal('impuestoInternoUnitario', 12, 2);
  57 + table.decimal('impuestoInterno1Unitario', 12, 2);
  58 + table.decimal('impuestoInterno2Unitario', 12, 2);
  59 + table.decimal('ivaServicioUnitario', 12, 2);
  60 + table.decimal('ivaUnitario', 12, 2);
  61 + table.decimal('tasaIva', 12, 2);
  62 + })
  63 +};
migrations/20190311170816_v0.8.0.js
... ... @@ -0,0 +1,23 @@
  1 +const md5 = require('md5');
  2 +
  3 +exports.up = function(knex, Promise) {
  4 +
  5 + return knex.schema
  6 + .table('APAREMP', function(table) {
  7 +
  8 + table.string('idEmpresa');
  9 + }).then(function() {
  10 + return Promise.all([
  11 + knex('APAREMP').update({ idEmpresa: md5(new Date().getTime())})
  12 + ]);
  13 + });
  14 +
  15 +};
  16 +
  17 +exports.down = function(knex, Promise) {
  18 + return Promise.all([
  19 + knex.schema.table('APAREMP', function(table) {
  20 + table.dropColumn('idEmpresa');
  21 + })
  22 + ]);
  23 +};
migrations/20190412094131_v0.9.0.js
... ... @@ -0,0 +1,18 @@
  1 +
  2 +exports.up = function(knex, Promise) {
  3 + return Promise.all([
  4 + knex.schema
  5 + .createTable('remito_punto_descarga', function(table) {
  6 + table.increments();
  7 + table.bigInteger('idPuntoDescarga').unsigned();
  8 + table.bigInteger('idRemito').unsigned();
  9 + })
  10 + ]);
  11 +};
  12 +
  13 +exports.down = function(knex, Promise) {
  14 + return Promise.all([
  15 + knex.schema
  16 + .dropTable('remito_punto_descarga')
  17 + ]);
  18 +};
migrations/20190425163004_v0.9.1.js
... ... @@ -0,0 +1,17 @@
  1 +
  2 +exports.up = function(knex, Promise) {
  3 + return Promise.all([
  4 + knex.schema.createTable('parametros', function(table) {
  5 + table.increments();
  6 + table.string('modulo');
  7 + table.string('jsonText', [4000]);
  8 + table.string('jsonText2', [4000]);
  9 + })
  10 + ]);
  11 +};
  12 +
  13 +exports.down = function(knex, Promise) {
  14 + return Promise.all([
  15 + knex.schema.dropTable('parametros')
  16 + ]);
  17 +};
migrations/20190524103556_v0.10.0.js
... ... @@ -0,0 +1,37 @@
  1 +
  2 +exports.up = function (knex, Promise) {
  3 + return Promise.all([
  4 + knex.schema
  5 + .table('nota_pedido', function (table) {
  6 + table.bigInteger('idListaPrecio').unsigned();
  7 + table.dropColumn('idPrecioCondicion');
  8 + })
  9 + .table('plazo_pago', function (table) {
  10 + table.bigInteger('idCliente').unsigned();
  11 + table.dropColumn('idPreciosCondiciones');
  12 +
  13 + })
  14 + .table('remito', function (table) {
  15 + table.bigInteger('idListaPrecio').unsigned();
  16 + table.dropColumn('idPrecioCondicion');
  17 + })
  18 + ]);
  19 +};
  20 +
  21 +exports.down = function (knex, Promise) {
  22 + return Promise.all([
  23 + knex.schema
  24 + .table('nota_pedido', function (table) {
  25 + table.dropColumn('idListaPrecio');
  26 + table.bigInteger('idPrecioCondicion').unsigned();
  27 + })
  28 + .table('plazo_pago', function (table) {
  29 + table.dropColumn('idCliente');
  30 + table.bigInteger('idPreciosCondiciones').unsigned();
  31 + })
  32 + .table('remito', function (table) {
  33 + table.dropColumn('idListaPrecio');
  34 + table.bigInteger('idPrecioCondicion').unsigned();
  35 + })
  36 + ]);
  37 +};
migrations/20190611150606_v0.11.0.js
... ... @@ -0,0 +1,18 @@
  1 +
  2 +exports.up = function(knex, Promise) {
  3 + return Promise.all([
  4 + knex.schema
  5 + .table('hoja_ruta', function (table) {
  6 + table.bigInteger('abierta').unsigned();
  7 + })
  8 + ]);
  9 +};
  10 +
  11 +exports.down = function(knex, Promise) {
  12 + return Promise.all([
  13 + knex.schema
  14 + .table('hoja_ruta', function (table) {
  15 + table.dropColumn('abierta');
  16 + })
  17 + ]);
  18 +};