What is this? CASCADE clausule on DROP COLUMN???

24 views
Skip to first unread message

RompePC

unread,
Aug 25, 2016, 11:09:42 AM8/25/16
to Django users
I did a migration of Django, and then applied a sqlmigrate, giving me this output...

BEGIN;
--
-- Remove field my_column from my_table
--
ALTER TABLE `my_table` DROP COLUMN `my_column` CASCADE;

I don't find info about it, and I've never seen something like this in my MySQL experience. And the best part is that works (although it is marked as a syntax error). Can anyone throw me some light about it?

Erik Cederstrand

unread,
Aug 25, 2016, 12:19:54 PM8/25/16
to Django Users
Are you using MySQL as your backend? I believe that syntax is only for postgresql. CASCADE defines what to do if anything outside the table references the column. CASCADE will drop these references.

Erik

RompePC

unread,
Aug 25, 2016, 12:31:33 PM8/25/16
to Django users
Hi,

I searched for it, and looks like Django uses a general schema constants for common commands (like ALTER). It is stored inside a class, which is the parent class of the rest of the RDBMS schemas. And it isn't replaced, so it justs assumes the value of the parent.

More info https://github.com/django/django/tree/master/django/db/backends . Search in base/schema.py and mysql/schema.py

Would be nice if some could do a pull request modifying the command for MySQL, only to not get the error syntax (it is just a negative trim).
Reply all
Reply to author
Forward
0 new messages