summaryrefslogtreecommitdiff
path: root/docs/intro
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2022-08-26 21:42:44 +0200
committerGitHub <noreply@github.com>2022-08-26 21:42:44 +0200
commit081871bc20cc8b28481109b8dcadc321e177e6be (patch)
tree3b4a2cfa033ae6c4f25719af818ef0fa47d08756 /docs/intro
parent166a3b32632c141541d1c3f0eff18e1d8b389404 (diff)
downloaddjango-081871bc20cc8b28481109b8dcadc321e177e6be.tar.gz
Refs #30511 -- Updated docs about auto-incrementing primary keys on PostgreSQL.
Follow up to 2eea361eff58dd98c409c5227064b901f41bd0d6.
Diffstat (limited to 'docs/intro')
-rw-r--r--docs/intro/tutorial02.txt14
1 files changed, 7 insertions, 7 deletions
diff --git a/docs/intro/tutorial02.txt b/docs/intro/tutorial02.txt
index df595e947c..ee0707456d 100644
--- a/docs/intro/tutorial02.txt
+++ b/docs/intro/tutorial02.txt
@@ -274,7 +274,7 @@ readability):
-- Create model Question
--
CREATE TABLE "polls_question" (
- "id" serial NOT NULL PRIMARY KEY,
+ "id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
"question_text" varchar(200) NOT NULL,
"pub_date" timestamp with time zone NOT NULL
);
@@ -282,10 +282,10 @@ readability):
-- Create model Choice
--
CREATE TABLE "polls_choice" (
- "id" serial NOT NULL PRIMARY KEY,
+ "id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
"choice_text" varchar(200) NOT NULL,
"votes" integer NOT NULL,
- "question_id" integer NOT NULL
+ "question_id" bigint NOT NULL
);
ALTER TABLE "polls_choice"
ADD CONSTRAINT "polls_choice_question_id_c5b4b260_fk_polls_question_id"
@@ -315,10 +315,10 @@ Note the following:
PostgreSQL to not enforce the foreign key until the end of the transaction.
* It's tailored to the database you're using, so database-specific field types
- such as ``auto_increment`` (MySQL), ``serial`` (PostgreSQL), or ``integer
- primary key autoincrement`` (SQLite) are handled for you automatically. Same
- goes for the quoting of field names -- e.g., using double quotes or
- single quotes.
+ such as ``auto_increment`` (MySQL), ``bigint PRIMARY KEY GENERATED BY DEFAULT
+ AS IDENTITY`` (PostgreSQL), or ``integer primary key autoincrement`` (SQLite)
+ are handled for you automatically. Same goes for the quoting of field names
+ -- e.g., using double quotes or single quotes.
* The :djadmin:`sqlmigrate` command doesn't actually run the migration on your
database - instead, it prints it to the screen so that you can see what SQL