@@ 667-684 (lines=18) @@ | ||
664 | { |
|
665 | $instructions = new AlterInstructions(); |
|
666 | ||
667 | foreach ($columns as $column) { |
|
668 | $rows = $this->fetchAll(sprintf( |
|
669 | "SELECT |
|
670 | CONSTRAINT_NAME |
|
671 | FROM information_schema.KEY_COLUMN_USAGE |
|
672 | WHERE REFERENCED_TABLE_SCHEMA = DATABASE() |
|
673 | AND REFERENCED_TABLE_NAME IS NOT NULL |
|
674 | AND TABLE_NAME = '%s' |
|
675 | AND COLUMN_NAME = '%s' |
|
676 | ORDER BY POSITION_IN_UNIQUE_CONSTRAINT", |
|
677 | $tableName, |
|
678 | $column |
|
679 | )); |
|
680 | ||
681 | foreach ($rows as $row) { |
|
682 | $instructions->merge($this->getDropForeignKeyInstructions($tableName, $row['CONSTRAINT_NAME'])); |
|
683 | } |
|
684 | } |
|
685 | ||
686 | if (empty($instructions->getAlterParts())) { |
|
687 | throw new \InvalidArgumentException(sprintf( |
@@ 855-876 (lines=22) @@ | ||
852 | { |
|
853 | $instructions = new AlterInstructions(); |
|
854 | ||
855 | foreach ($columns as $column) { |
|
856 | $rows = $this->fetchAll(sprintf( |
|
857 | "SELECT |
|
858 | tc.constraint_name, |
|
859 | tc.table_name, kcu.column_name, |
|
860 | ccu.table_name AS referenced_table_name, |
|
861 | ccu.column_name AS referenced_column_name |
|
862 | FROM |
|
863 | information_schema.table_constraints AS tc |
|
864 | JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name |
|
865 | JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name |
|
866 | WHERE constraint_type = 'FOREIGN KEY' AND tc.table_name = '%s' and ccu.column_name='%s' |
|
867 | ORDER BY kcu.ordinal_position", |
|
868 | $tableName, |
|
869 | $column |
|
870 | )); |
|
871 | foreach ($rows as $row) { |
|
872 | $instructions->merge( |
|
873 | $this->getDropForeignKeyInstructions($tableName, $row['constraint_name']) |
|
874 | ); |
|
875 | } |
|
876 | } |
|
877 | ||
878 | return $instructions; |
|
879 | } |