mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[4.1.x] Refs #30511 -- Updated docs about auto-incrementing primary keys on PostgreSQL.
Follow up to2eea361eff. Backport of081871bc20from main
This commit is contained in:
		| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user