These are chat archives for db-migrate/node-db-migrate

23rd
Feb 2016
Diego Aguilar Aguilar
@diegoaguilar
Feb 23 2016 06:03
Hello, I'm trying to run following migration in order to get automatically uuid id generation for my rows
CREATE EXTENSION pgcrypto;

CREATE TABLE users (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  first_name VARCHAR(40) NOT NULL,
  last_name VARCHAR(40) NOT NULL,
  email VARCHAR(255) NOT NULL,
  password_digest VARCHAR(255) NOT NULL,
  is_admin BOOLEAN NOT NULL DEFAULT 'f',
  created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
  updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);

CREATE UNIQUE INDEX ix_users_email ON users (email);
CREATE UNIQUE INDEX ix_users_slug ON users (slug);
and getting this error :(
received data: CREATE EXTENSION pgcrypto;

CREATE TABLE users (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  first_name VARCHAR(40) NOT NULL,
  last_name VARCHAR(40) NOT NULL,
  email VARCHAR(255) NOT NULL,
  password_digest VARCHAR(255) NOT NULL,
  is_admin BOOLEAN NOT NULL DEFAULT 'f',
  created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
  updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);

CREATE UNIQUE INDEX ix_users_email ON users (email);
CREATE UNIQUE INDEX ix_users_slug ON users (slug);

[ERROR] error: function gen_random_uuid() does not exist
    at Connection.parseE (/home/vagrant/xolito/xolito-api/node_modules/pg/lib/connection.js:539:11)
    at Connection.parseMessage (/home/vagrant/xolito/xolito-api/node_modules/pg/lib/connection.js:366:17)
    at Socket.<anonymous> (/home/vagrant/xolito/xolito-api/node_modules/pg/lib/connection.js:105:22)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at readableAddChunk (_stream_readable.js:146:16)
    at Socket.Readable.push (_stream_readable.js:110:10)
    at TCP.onread (net.js:523:20)
any suggestions?
Tobias Gurtzick
@wzrdtales
Feb 23 2016 08:15
As this comes directly from the PG driver node_modules/pg/lib/connection.js gen_random_uuid() seems to not be existent on your database. May I ask which postgres version you do use? As this function was introduced with 9.4 and also another question do you have installed the pgcrypto module?
Diego Aguilar Aguilar
@diegoaguilar
Feb 23 2016 10:31
ohh ... :(
it's 9.3