naveteam / back-boilerplate

A boilerplate for building RESTful APIs using Node.js, PostgreSQL, koa, knex, bookshelf.
35 stars 19 forks source link

fix: removing unnecessary methods on migrations #31

Closed guivahl closed 4 years ago

guivahl commented 4 years ago

Citando a documentação do Postgres na parte de primary keys (https://www.postgresql.org/docs/8.1/ddl-constraints.html):

Technically, a primary key constraint is simply a combination of a unique constraint and a not-null constraint. 
So, the following two table definitions accept the same data:

CREATE TABLE products (
    product_no integer UNIQUE NOT NULL,
    name text,
    price numeric
);
CREATE TABLE products (
    product_no integer PRIMARY KEY,
    name text,
    price numeric
);

Assim sendo, não há necessidade dos métodos .unique() e .notNullable() junto ao método .primary(), pois se tornam redundantes.