Changes PKs in realworld postgres to SERIAL

`GENERATED` was added in Postgres 12 and we test as far back as 9
This commit is contained in:
Samani G. Gikandi 2020-04-15 12:01:18 -07:00 committed by Ryan Leckey
parent 9fb523d4e8
commit 841d9a7f45

View file

@ -1,8 +1,5 @@
DROP VIEW IF EXISTS profiles CASCADE ;
DROP TABLE users, followers, articles, favorite_articles, tags, comments CASCADE ;
CREATE TABLE IF NOT EXISTS users (
user_id INT NOT NULL GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
user_id SERIAL PRIMARY KEY,
email TEXT UNIQUE NOT NULL,
password TEXT NOT NULL,
@ -20,7 +17,7 @@ SELECT user_id, username, bio, image
FROM users;
CREATE TABLE IF NOT EXISTS articles (
article_id INT NOT NULL GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
article_id SERIAL PRIMARY KEY,
title TEXT UNIQUE NOT NULL,
description TEXT NOT NULL,
slug TEXT UNIQUE NOT NULL,
@ -59,7 +56,7 @@ CREATE TABLE IF NOT EXISTS tags (
);
CREATE TABLE IF NOT EXISTS comments (
comment_id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
comment_id SERIAL PRIMARY KEY,
body TEXT NOT NULL,
article_id INT NOT NULL REFERENCES articles (article_id) ON DELETE CASCADE,