mirror of
https://github.com/launchbadge/sqlx
synced 2024-11-10 14:34:19 +00:00
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:
parent
9fb523d4e8
commit
841d9a7f45
1 changed files with 3 additions and 6 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue