Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declaration of multiple column in a single primary key #31

Closed
xsellier opened this issue Oct 5, 2015 · 4 comments
Closed

Declaration of multiple column in a single primary key #31

xsellier opened this issue Oct 5, 2015 · 4 comments

Comments

@xsellier
Copy link

xsellier commented Oct 5, 2015

We should be able to declare a primary key on multiple column.
Here an example:

  // Linked table declarations
  pgm.createTable('test', {
    test  : {
      type       : 'bigserial',
      primaryKey : true,
      notNull    : true
    },
    test2      : {
      type       : 'bigserial',
      primaryKey : true,
      notNull    : true
    }
  });

Actual SQL

CREATE TABLE "test" (
  test bigserial PRIMARY KEY NOT NULL, 
  test2 bigserial PRIMARY KEY NOT NULL
);

Here sql expected

CREATE TABLE "test"
(
  test bigserial NOT NULL,
  test2 bigserial NOT NULL,
  CONSTRAINT test_pkey PRIMARY KEY (test, test2)
)

Currently we've got an error:

> Rolling back attempted migration ...
error: les clés primaires multiples ne sont pas autorisées pour la table « provider_user »
    at Connection.parseE (/opt/node_modules/node-pg-migrate/node_modules/pg/lib/connection.js:534:11)
    at Connection.parseMessage (/opt/node_modules/node-pg-migrate/node_modules/pg/lib/connection.js:361:17)
    at Socket.<anonymous> (/opt/node_modules/node-pg-migrate/node_modules/pg/lib/connection.js:105:22)
    at Socket.emit (events.js:107:17)
    at readableAddChunk (_stream_readable.js:163:16)
    at Socket.Readable.push (_stream_readable.js:126:10)
    at TCP.onread (net.js:538:20)
@dolezel
Copy link
Contributor

dolezel commented Feb 3, 2017

Fixed in 1.0.0

@dolezel dolezel closed this as completed Feb 3, 2017
@modeswitch
Copy link

I'm having a similar issue except I need to put a UNIQUE constraint over multiple columns during table creation. Do I need to use a custom statement in that case?

@dolezel
Copy link
Contributor

dolezel commented Sep 18, 2017

Yes, for now. I will look on it...

@dolezel
Copy link
Contributor

dolezel commented Sep 21, 2017

@modeswitch see #114

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants