Reputation: 1116
I am trying to create a table with the following query using the pg npm module (v7):
CREATE TABLE subscriptions(
id SERIAL PRIMARY KEY,
stripe_id VARCHAR(40) UNIQUE NOT NULL,
user INTEGER REFERENCES users,
plan VARCHAR(40) NOT NULL,
active BOOLEAN NOT NULL,
start DATE NOT NULL,
end DATE DEFAULT NULL
);
This seems to match the docs but it is throwing an error:
error: syntax error at or near "user"
The users table has a serial primary key for id, anyone know why this isn't working?
Edit: here's the docs for reference - https://www.postgresql.org/docs/9.4/static/ddl-constraints.html#DDL-CONSTRAINTS-FK
I'm using postgresql version 9.4.
Upvotes: 0
Views: 149
Reputation: 792
user is a reserved keyword in postgresql. You may use any other column name in its place
Refer the postgresql documentation for the complete list of keywords - Key Words List
According to it, end is also reserved. So the last line of your code will generate an error
Upvotes: 1