agendas: change Event id field to have a BigAutoField (#74008) #33

Merged
lguerin merged 1 commits from wip/74008-bigautofield into main 2023-02-03 11:17:54 +01:00
Owner
No description provided.
lguerin reviewed 2023-02-02 11:34:20 +01:00
@ -0,0 +10,4 @@
ALTER TABLE "agendas_event_resources" ALTER COLUMN "event_id" TYPE bigint USING "event_id"::bigint;
ALTER TABLE "agendas_eventcancellationreport" ALTER COLUMN "event_id" TYPE bigint USING "event_id"::bigint;
ALTER TABLE "agendas_recurrenceexceptionsreport_events" ALTER COLUMN "event_id" TYPE bigint USING "event_id"::bigint;
"""
Author
Owner

laisser django faire ne suffit pas:

SET CONSTRAINTS "agendas_event_primary_event_id_539e724e_fk_agendas_event_id" IMMEDIATE; ALTER TABLE "agendas_event" DROP CONSTRAINT "agendas_event_primary_event_id_539e724e_fk_agendas_event_id"
ALTER TABLE "agendas_event" ALTER COLUMN "id" TYPE bigint USING "id"::bigint
NOTICE:  DROP cascade sur valeur par défaut pour  colonne id de table agendas_event
DROP SEQUENCE IF EXISTS "agendas_event_id_seq" CASCADE
CREATE SEQUENCE "agendas_event_id_seq"
ALTER TABLE "agendas_event" ALTER COLUMN "id" SET DEFAULT nextval('"agendas_event_id_seq"')
SELECT setval('"agendas_event_id_seq"', MAX("id")) FROM "agendas_event"
ALTER TABLE "agendas_event" ALTER COLUMN "primary_event_id" TYPE bigint USING "primary_event_id"::bigint
ALTER TABLE "agendas_event" ADD CONSTRAINT "agendas_event_primary_event_id_539e724e_fk" FOREIGN KEY ("primary_event_id") REFERENCES "agendas_event" ("id") DEFERRABLE INITIALLY DEFERRED

Il drop la séquence (gloups), et ne traite que le model Event, pas les FK des autres models.

laisser django faire ne suffit pas: ``` SET CONSTRAINTS "agendas_event_primary_event_id_539e724e_fk_agendas_event_id" IMMEDIATE; ALTER TABLE "agendas_event" DROP CONSTRAINT "agendas_event_primary_event_id_539e724e_fk_agendas_event_id" ALTER TABLE "agendas_event" ALTER COLUMN "id" TYPE bigint USING "id"::bigint NOTICE: DROP cascade sur valeur par défaut pour colonne id de table agendas_event DROP SEQUENCE IF EXISTS "agendas_event_id_seq" CASCADE CREATE SEQUENCE "agendas_event_id_seq" ALTER TABLE "agendas_event" ALTER COLUMN "id" SET DEFAULT nextval('"agendas_event_id_seq"') SELECT setval('"agendas_event_id_seq"', MAX("id")) FROM "agendas_event" ALTER TABLE "agendas_event" ALTER COLUMN "primary_event_id" TYPE bigint USING "primary_event_id"::bigint ALTER TABLE "agendas_event" ADD CONSTRAINT "agendas_event_primary_event_id_539e724e_fk" FOREIGN KEY ("primary_event_id") REFERENCES "agendas_event" ("id") DEFERRABLE INITIALLY DEFERRED ``` Il drop la séquence (gloups), et ne traite que le model Event, pas les FK des autres models.
lguerin requested review from pducroquet 2023-02-02 11:34:57 +01:00
pducroquet requested changes 2023-02-02 11:40:25 +01:00
@ -0,0 +5,4 @@
sql_forwards_bigint = """
ALTER SEQUENCE "agendas_event_id_seq" as bigint MAXVALUE 9223372036854775807;
ALTER TABLE "agendas_event" ALTER COLUMN "id" TYPE bigint USING "id"::bigint;
ALTER TABLE "agendas_event" ALTER COLUMN "primary_event_id" TYPE bigint USING "primary_event_id"::bigint;
Owner

Un seul alter par table stp :)

Un seul alter par table stp :)
lguerin marked this conversation as resolved
lguerin force-pushed wip/74008-bigautofield from 766f4e650e to 95bdd66ffd 2023-02-02 11:45:06 +01:00 Compare
lguerin requested review from pducroquet 2023-02-02 11:46:11 +01:00
pducroquet approved these changes 2023-02-02 11:49:48 +01:00
pducroquet left a comment
Owner

C'est bon pour moi côté SQL.

C'est bon pour moi côté SQL.
lguerin reviewed 2023-02-02 14:08:27 +01:00
@ -2628,0 +2630,4 @@
cursor.execute("SELECT nextval('agendas_event_id_seq')")
row = cursor.fetchone()
if row[0] < 2**31:
cursor.execute("ALTER SEQUENCE agendas_event_id_seq RESTART WITH %s;" % 2**31)
Author
Owner

pour tester au moins une fois, mais pas forcément sur toutes les FK, que ça passe sur un bigint
mais on peut virer ça maintenant que jenkins est passé au moins une fois

pour tester au moins une fois, mais pas forcément sur toutes les FK, que ça passe sur un bigint mais on peut virer ça maintenant que jenkins est passé au moins une fois
lguerin reviewed 2023-02-02 14:08:27 +01:00
@ -2628,0 +2630,4 @@
cursor.execute("SELECT nextval('agendas_event_id_seq')")
row = cursor.fetchone()
if row[0] < 2**31:
cursor.execute("ALTER SEQUENCE agendas_event_id_seq RESTART WITH %s;" % 2**31)
Author
Owner

pour tester au moins une fois, mais pas forcément sur toutes les FK, que ça passe sur un bigint
mais on peut virer ça maintenant que jenkins est passé au moins une fois

pour tester au moins une fois, mais pas forcément sur toutes les FK, que ça passe sur un bigint mais on peut virer ça maintenant que jenkins est passé au moins une fois
fpeters approved these changes 2023-02-03 11:15:54 +01:00
lguerin merged commit 4db8e384c9 into main 2023-02-03 11:17:54 +01:00
lguerin deleted branch wip/74008-bigautofield 2023-02-03 11:17:54 +01:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: entrouvert/chrono#33
No description provided.