We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In Postgres, setting NOT NULL on an existing column blocks reads and writes while every row is checked, which is problematic on large tables.
NOT NULL
For reference, have a look here.
This might be a bit hard to check as the migration file will look something like below. But perhaps it makes sense to look at the generated SQL?
class Migration(migrations.Migration): operations = [ migrations.AlterField( model_name='foo', name='field_name', field=models.ForeignKey(blank=True, on_delete=django.db.models.deletion.PROTECT, related_name='related_field_name', to='bar'), ), ]
While the generated SQL becomes like below (the interesting part is ALTER TABLE "foo" ALTER COLUMN "field_name_id" SET NOT NULL;)
ALTER TABLE "foo" ALTER COLUMN "field_name_id" SET NOT NULL;
BEGIN; SET CONSTRAINTS "foo_field_name__f89f691c_fk_bar" IMMEDIATE; ALTER TABLE "foo" DROP CONSTRAINT "foo_field_name__f89f691c_fk_bar"; ALTER TABLE "foo" ALTER COLUMN "field_name_id" SET NOT NULL; ALTER TABLE "foo" ADD CONSTRAINT "foo_field_name__f89f691c_fk_bar" FOREIGN KEY ("field_name_id") REFERENCES "bar" ("id") DEFERRABLE INITIALLY DEFERRED; COMMIT;
The text was updated successfully, but these errors were encountered:
No branches or pull requests
In Postgres, setting
NOT NULL
on an existing column blocks reads and writes while every row is checked, which is problematic on large tables.For reference, have a look here.
This might be a bit hard to check as the migration file will look something like below. But perhaps it makes sense to look at the generated SQL?
While the generated SQL becomes like below (the interesting part is
ALTER TABLE "foo" ALTER COLUMN "field_name_id" SET NOT NULL;
)The text was updated successfully, but these errors were encountered: