I have created a database with several tables, including tables named users and recipes. At last I have created a table of comments. Here is how I defined those tables:
CREATE TABLE recipes(
id SERIAL PRIMARY KEY,
recipe_name TEXT NOT NULL,
num_portions INTEGER,
preparation_time INTEGER,
cooking_time INTEGER
);
CREATE TABLE users(
id SERIAL PRIMARY KEY,
username TEXT NOT NULL,
user_password TEXT NOT NULL UNIQUE,
last_login DATE
);
CREATE TABLE comments(
id SERIAL PRIMARY KEY,
id_user INTEGER NOT NULL REFERENCES users(id),
id_recipe INTEGER NOT NULL REFERENCES recipes(id),
comment_description TEXT NOT NULL
);
Commands such as select and insert worked on the table comments until I tried to add a column, with the following command:
ALTER TABLE comments
ADD COLUMN date_of_comment TIMESTAMP;
This failed to succeed and it ran indefinitely. I wanted to drop it with DROP TABLE comments
, which ran indefinitely as well. Now when I try to run any command, such as SELECT, on this table it runs indefinitely.
I tried to create the table comments again to check if it got deleted when I tried to drop it with the command:
CREATE TABLE comments(
id SERIAL PRIMARY KEY,
id_user INTEGER NOT NULL REFERENCES users(id),
id_recipe INTEGER NOT NULL REFERENCES recipes(id),
comment_description TEXT NOT NULL,
date_of_comment TIMESTAMP
);
However I get an error "relation "comments" already exists" and "Cannot read property 'document' of undefined". Does anyone know what went wrong?