_$: apt-get install postgresql-contrib-9.1

If we are going to bring some data from database to database, we will need to install the `dblink` extension in the database.

Example:

  • source: dtbsrc user: fnc password: host: 192.168.1.196
  • destino: dtbdst
(postgres@host)_$: psql dtbdst
dtbdst=# CREATE EXTENSION dblink;

After that, run the migration script:

-- -------------------------------------------------------------
-- SQL Script for migrate old `db` database 0.9 to new 0.10
-- -------------------------------------------------------------

-- -----------------------------------------------------
-- Table `clientes` to `client`
-- -----------------------------------------------------
INSERT INTO client (id, type, webaddid,
refinternal, logintype, isactive, email,
password, languagecod, treatment, firstname,
lastname, emailalt, phone, phonealt,
dateadd, datelast, notestx, notesclient)
SELECT * FROM dblink('hostaddr=192.168.1.196 dbname=dbsrc user=fnc password=<password>','SELECT id, ''rg'', 1, refinterna, ''fi'', activo, email,
password, idiomacod, ''o'', nombre, apellidos,
emailalt, telefono, telefonoalt, fechaalta,
fechaultimo, notasfincas, notascliente FROM clientes')
AS t(id int, type text, webaddid int,
refinternal int, logintype text, isactive boolean, email text,
password text, languagecod text, treatment text, firstname text,
lastname text, emailalt text, phone text, phonealt text,
dateadd timestamp, datelast timestamp, notestx text, notesclient text);

-- -----------------------------------------------------
-- Table `clientes` to `clientregistered`
-- -----------------------------------------------------
INSERT INTO clientregistered (clientid, legalname,
commercialname, fiscalcod, loc1countrycod, address,
postalcod, url, logourl, picbroker,
istop, numliststop)
SELECT * FROM dblink('hostaddr=192.168.1.196 dbname=dbsrc user=fnc password=<password>','SELECT id, razonsocial,
nombrecomercial, fiscalcod, paiscod, direccion,
postalcod,url, logourl, fotovendedor, False, 0
FROM clientes')
AS t(clientid int, legalname text,
commercialname text, fiscalcod text, loc1countrycod text, address text,
postalcod text, url text, logourl text, picbroker text,
istop boolean, numliststop int);

...