Skip to content

Commit dbcd4e2

Browse files
update adding columns
1 parent 76196d9 commit dbcd4e2

File tree

1 file changed

+4
-1
lines changed
  • develop-docs/backend/application-domains/database-migrations

1 file changed

+4
-1
lines changed

develop-docs/backend/application-domains/database-migrations/index.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,12 @@ With postgres 14, columns can be added to tables of all sizes as deploy time
440440
migrations if you follow the guidelines on default values & allowing nulls. When
441441
creating new columns they should either be:
442442

443-
- Not null with a default. https://develop.sentry.dev/database-migrations/#adding-not-null-to-columns
443+
- Not null with a default
444444
- Created as nullable. If no default value can be set on the column, then it's best just to make it nullable.
445445

446+
For nullable columns with a constraint and not null columns with a default, see [Adding Constraints to Columns](#adding-constraints-to-columns-including-not-null). For bigger tables, these constraints can lock the table and cause downtime.
447+
448+
446449
### Adding Columns With a Default
447450

448451
Since we run Postgres >= 14 in production we are able to add columns with a default. To do so, instead of using `default=<your_default>`, use `db_default=<your_default>`. This tells Django to set a default at the database level and manage it there, rather than managing it in application code.

0 commit comments

Comments
 (0)