mirror of
https://github.com/django/django.git
synced 2025-08-03 02:23:12 +00:00
Refs #30511 -- Updated docs about auto-incrementing primary keys on PostgreSQL.
Follow up to 2eea361eff
.
This commit is contained in:
parent
166a3b3263
commit
081871bc20
4 changed files with 17 additions and 13 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue