Skip to content

Commit 4762d48

Browse files
committed
small fixes
1 parent d9c9501 commit 4762d48

File tree

1 file changed

+4
-4
lines changed
  • develop-docs/api-server/application-domains/database-migrations

1 file changed

+4
-4
lines changed

develop-docs/api-server/application-domains/database-migrations/index.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ This is complicated due to our deploy process. When we deploy, we run migrations
145145

146146
To avoid this, follow these steps:
147147

148-
- (Optional, but ideal) Make a PR to remove all uses of the column in the codebase in a separate PR. This mostly helps with code cleanliness. This should be merged ahead of the migration prs, but we don't need to worry about whether it is deployed first.
148+
- Make a PR to remove all uses of the column in the codebase in a separate PR. This mostly helps with code cleanliness. This should be merged ahead of the migration prs, but we don't need to worry about whether it is deployed first.
149149
- Make another PR that:
150-
- Checks if the column is either not nullable, or doesn't have a db_default set. If either of these is true, then make it nullable via `null=True`.
150+
- Checks if the column is either not nullable, or doesn't have a `db_default` set. If either of these is true, then make it nullable via `null=True`.
151151
- If the column is a foreign key, remove the database level foreign key constraint it by setting `db_constraint=False`.
152152
- Remove the column and in the generated migration use `SafeRemoveField(..., deletion_action=DeletionAction.MOVE_TO_PENDING)` to replace `RemoveField(...)`. This only marks the state for the column as removed.
153153
- Combine these migrations together to save making multiple deploys
@@ -239,15 +239,15 @@ operations = [
239239

240240
Then we deploy this and we're done. So to recap the steps here:
241241
- Remove all references to the column in the code in a separate pull request and merge. Doesn't matter if this deploys before the next step or not.
242-
- If the column has an foreign key constraint them remove it. If it's not null and has no db_default then mark it as nullable. Then delete the column using `SafeRemoveField(..., deletion_action=DeletionAction.MOVE_TO_PENDING)`. These operations can be in the same migration to save time.
242+
- If the column has an foreign key constraint them remove it. If it's not null and has no `db_default` then mark it as nullable. Then delete the column using `SafeRemoveField(..., deletion_action=DeletionAction.MOVE_TO_PENDING)`. These operations can be in the same migration to save time.
243243
- Deploy all previous before continuing.
244244
- Remove the column from the table in from Postgres using `SafeRemoveField(..., deletion_action=DeletionAction.DELETE),`
245245

246246
### Deleting Tables
247247

248248
Extra care is needed here if the table is referenced as a foreign key in other tables. In that case, first remove the foreign key columns in the other tables, then come back to this step.
249249

250-
- (Optional, but ideal) 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.
250+
- 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.
251251
- Make another pull request to:
252252
- Remove any database level foreign key constraints from this table to other tables by setting `db_constraint=False` on the columns.
253253
- 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.

0 commit comments

Comments
 (0)