I am now using Alembic 1.8, SQLAlchemy 1.4 and PostgreSQL
I would like to set my FK constraints as "DEFERRABLE INITIALLY IMMEDIATE".
I passed the FK options as shown below:
sa.Column(
"group_id",
sa.BigInteger,
sa.ForeignKey(
"auth_group.id",
onupdate="CASCADE",
ondelete="CASCADE",
deferrable=True,
initially="IMMEDIATE"
),
index=True,
),
It generates my "create table" SQL like this:
CONSTRAINT auth_user_groups_group_id_fkey FOREIGN KEY (group_id)
REFERENCES public.auth_group (id) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE CASCADE,
DEFERRABLE
I expected "DEFERRABLE INITIALLY IMMEDIATE" instead of "DEFERRABLE".
Please, let me know how to make the constraint as "DEFERRABLE INITIALLY IMMEDIATE".
Thank you.