| @@ 971-992 (lines=22) @@ | ||
| 968 | { |
|
| 969 | $instructions = new AlterInstructions(); |
|
| 970 | ||
| 971 | foreach ($columns as $column) { |
|
| 972 | $rows = $this->fetchAll(sprintf( |
|
| 973 | "SELECT |
|
| 974 | tc.constraint_name, |
|
| 975 | tc.table_name, kcu.column_name, |
|
| 976 | ccu.table_name AS referenced_table_name, |
|
| 977 | ccu.column_name AS referenced_column_name |
|
| 978 | FROM |
|
| 979 | information_schema.table_constraints AS tc |
|
| 980 | JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name |
|
| 981 | JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name |
|
| 982 | WHERE constraint_type = 'FOREIGN KEY' AND tc.table_name = '%s' and ccu.column_name='%s' |
|
| 983 | ORDER BY kcu.ordinal_position", |
|
| 984 | $tableName, |
|
| 985 | $column |
|
| 986 | )); |
|
| 987 | foreach ($rows as $row) { |
|
| 988 | $instructions->merge( |
|
| 989 | $this->getDropForeignKeyInstructions($tableName, $row['constraint_name']) |
|
| 990 | ); |
|
| 991 | } |
|
| 992 | } |
|
| 993 | ||
| 994 | return $instructions; |
|
| 995 | } |
|
| @@ 830-847 (lines=18) @@ | ||
| 827 | { |
|
| 828 | $instructions = new AlterInstructions(); |
|
| 829 | ||
| 830 | foreach ($columns as $column) { |
|
| 831 | $rows = $this->fetchAll(sprintf( |
|
| 832 | "SELECT |
|
| 833 | CONSTRAINT_NAME |
|
| 834 | FROM information_schema.KEY_COLUMN_USAGE |
|
| 835 | WHERE REFERENCED_TABLE_SCHEMA = DATABASE() |
|
| 836 | AND REFERENCED_TABLE_NAME IS NOT NULL |
|
| 837 | AND TABLE_NAME = '%s' |
|
| 838 | AND COLUMN_NAME = '%s' |
|
| 839 | ORDER BY POSITION_IN_UNIQUE_CONSTRAINT", |
|
| 840 | $tableName, |
|
| 841 | $column |
|
| 842 | )); |
|
| 843 | ||
| 844 | foreach ($rows as $row) { |
|
| 845 | $instructions->merge($this->getDropForeignKeyInstructions($tableName, $row['CONSTRAINT_NAME'])); |
|
| 846 | } |
|
| 847 | } |
|
| 848 | ||
| 849 | if (empty($instructions->getAlterParts())) { |
|
| 850 | throw new \InvalidArgumentException(sprintf( |
|