| @@ 984-1005 (lines=22) @@ | ||
| 981 | { |
|
| 982 | $instructions = new AlterInstructions(); |
|
| 983 | ||
| 984 | foreach ($columns as $column) { |
|
| 985 | $rows = $this->fetchAll(sprintf( |
|
| 986 | "SELECT |
|
| 987 | tc.constraint_name, |
|
| 988 | tc.table_name, kcu.column_name, |
|
| 989 | ccu.table_name AS referenced_table_name, |
|
| 990 | ccu.column_name AS referenced_column_name |
|
| 991 | FROM |
|
| 992 | information_schema.table_constraints AS tc |
|
| 993 | JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name |
|
| 994 | JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name |
|
| 995 | WHERE constraint_type = 'FOREIGN KEY' AND tc.table_name = '%s' and ccu.column_name='%s' |
|
| 996 | ORDER BY kcu.ordinal_position", |
|
| 997 | $tableName, |
|
| 998 | $column |
|
| 999 | )); |
|
| 1000 | foreach ($rows as $row) { |
|
| 1001 | $instructions->merge( |
|
| 1002 | $this->getDropForeignKeyInstructions($tableName, $row['constraint_name']) |
|
| 1003 | ); |
|
| 1004 | } |
|
| 1005 | } |
|
| 1006 | ||
| 1007 | return $instructions; |
|
| 1008 | } |
|
| @@ 843-860 (lines=18) @@ | ||
| 840 | { |
|
| 841 | $instructions = new AlterInstructions(); |
|
| 842 | ||
| 843 | foreach ($columns as $column) { |
|
| 844 | $rows = $this->fetchAll(sprintf( |
|
| 845 | "SELECT |
|
| 846 | CONSTRAINT_NAME |
|
| 847 | FROM information_schema.KEY_COLUMN_USAGE |
|
| 848 | WHERE REFERENCED_TABLE_SCHEMA = DATABASE() |
|
| 849 | AND REFERENCED_TABLE_NAME IS NOT NULL |
|
| 850 | AND TABLE_NAME = '%s' |
|
| 851 | AND COLUMN_NAME = '%s' |
|
| 852 | ORDER BY POSITION_IN_UNIQUE_CONSTRAINT", |
|
| 853 | $tableName, |
|
| 854 | $column |
|
| 855 | )); |
|
| 856 | ||
| 857 | foreach ($rows as $row) { |
|
| 858 | $instructions->merge($this->getDropForeignKeyInstructions($tableName, $row['CONSTRAINT_NAME'])); |
|
| 859 | } |
|
| 860 | } |
|
| 861 | ||
| 862 | if (empty($instructions->getAlterParts())) { |
|
| 863 | throw new \InvalidArgumentException(sprintf( |
|