1

Django created a migration for dropping a field from a table:

ALTER TABLE "my_table" DROP COLUMN "my_deprecated_field" CASCADE;
COMMIT;

I would like to know which consquences the CASCADE has, i.e. which other columns, tables, triggers, etc. are going to be affected by it.

Since there is no EXPLAIN ALTER, which other means do I have to find out?

ezdazuzena
  • 6,120
  • 6
  • 41
  • 71

1 Answers1

0

I think it'll remove all the objects which are dependent or having reference(foreign key, etc) to this object too.

Assume Table A is having non-nullable foreign key to Table B.

If someone drops Table B, what will happen to Table A ? Table A rows will point to what ? It can't point to null, as it's non-nullable.

CASCASE come into picture here and using it on Table B will lead to dropping off of Table A rows also.

You can see a example here http://www.postgresqltutorial.com/postgresql-drop-column/

Umair Mohammad
  • 4,489
  • 2
  • 20
  • 34
  • Thanks for your answer. I would like to get a full list of things that are going to be removed. I read the documenation, but I do not know which parts of my database exactly will be affected. – ezdazuzena May 22 '19 at 12:08
  • This is false. The depend objects are the **constraints**, not the rows. `Table A` will keep all its data, but the field that was referring to `Table B` will not be referring to anything anymore – JGH May 22 '19 at 12:10