diff --git a/develop-docs/backend/application-domains/database-migrations/index.mdx b/develop-docs/backend/application-domains/database-migrations/index.mdx index 46606c7210737..37288ed46630d 100644 --- a/develop-docs/backend/application-domains/database-migrations/index.mdx +++ b/develop-docs/backend/application-domains/database-migrations/index.mdx @@ -440,9 +440,12 @@ With postgres 14, columns can be added to tables of all sizes as deploy time migrations if you follow the guidelines on default values & allowing nulls. When creating new columns they should either be: -- Not null with a default. https://develop.sentry.dev/database-migrations/#adding-not-null-to-columns +- Not null with a default - Created as nullable. If no default value can be set on the column, then it's best just to make it nullable. +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. + + ### Adding Columns With a Default Since we run Postgres >= 14 in production we are able to add columns with a default. To do so, instead of using `default=`, use `db_default=`. This tells Django to set a default at the database level and manage it there, rather than managing it in application code.