From dca3b06b23ffc23ccc324b29f15ece25ea09c52a Mon Sep 17 00:00:00 2001 From: Colleen O'Rourke Date: Tue, 3 Dec 2024 15:06:23 -0800 Subject: [PATCH] ref(migrations): Add instructions for hybrid cloud foreign key --- .../application-domains/database-migrations/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/develop-docs/api-server/application-domains/database-migrations/index.mdx b/develop-docs/api-server/application-domains/database-migrations/index.mdx index 6c52a0e5ef4d6..671f3f2c5edd9 100644 --- a/develop-docs/api-server/application-domains/database-migrations/index.mdx +++ b/develop-docs/api-server/application-domains/database-migrations/index.mdx @@ -287,7 +287,7 @@ Extra care is needed here if the table is referenced as a foreign key in other t - Make a pull request to remove all uses of the model in the codebase in a separate pull request. This mostly helps with code cleanliness. This should be merged ahead of the migration pull requests, but we don't need to worry about whether it is deployed first. - Make another pull request to: - - Remove any database level foreign key constraints from this table to other tables by setting `db_constraint=False` on the columns. + - Remove any database level foreign key constraints from this table to other tables by setting `db_constraint=False` on the columns. If it's a hybrid cloud foreign key, set `null=True` instead. - Remove the model and in the generated migration use `SafeDeleteModel(..., deletion_action=DeletionAction.MOVE_TO_PENDING)` to replace `DeleteModel(...)`. This only marks the state for the model as removed. - Deploy. It's important that all previous pull requests are in production before we remove the actual table. - Make a pull request that creates a new migration that has the same `SafeDeleteModel` operation as before, but set `deletion_action=DeletionAction.DELETE` instead. This deletes the actual table from Postgres.