Refs #30511 -- Updated docs about auto-incrementing primary keys on PostgreSQL.

Follow up to 2eea361eff.
This commit is contained in:
Mariusz Felisiak 2022-08-26 21:42:44 +02:00 committed by GitHub
parent 166a3b3263
commit 081871bc20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 13 deletions

View file

@ -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