| @@ 963-984 (lines=22) @@ | ||
| 960 | { |
|
| 961 | $instructions = new AlterInstructions(); |
|
| 962 | ||
| 963 | foreach ($columns as $column) { |
|
| 964 | $rows = $this->fetchAll(sprintf( |
|
| 965 | "SELECT |
|
| 966 | tc.constraint_name, |
|
| 967 | tc.table_name, kcu.column_name, |
|
| 968 | ccu.table_name AS referenced_table_name, |
|
| 969 | ccu.column_name AS referenced_column_name |
|
| 970 | FROM |
|
| 971 | information_schema.table_constraints AS tc |
|
| 972 | JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name |
|
| 973 | JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name |
|
| 974 | WHERE constraint_type = 'FOREIGN KEY' AND tc.table_name = '%s' and ccu.column_name='%s' |
|
| 975 | ORDER BY kcu.ordinal_position", |
|
| 976 | $tableName, |
|
| 977 | $column |
|
| 978 | )); |
|
| 979 | foreach ($rows as $row) { |
|
| 980 | $instructions->merge( |
|
| 981 | $this->getDropForeignKeyInstructions($tableName, $row['constraint_name']) |
|
| 982 | ); |
|
| 983 | } |
|
| 984 | } |
|
| 985 | ||
| 986 | return $instructions; |
|
| 987 | } |
|
| @@ 798-815 (lines=18) @@ | ||
| 795 | { |
|
| 796 | $instructions = new AlterInstructions(); |
|
| 797 | ||
| 798 | foreach ($columns as $column) { |
|
| 799 | $rows = $this->fetchAll(sprintf( |
|
| 800 | "SELECT |
|
| 801 | CONSTRAINT_NAME |
|
| 802 | FROM information_schema.KEY_COLUMN_USAGE |
|
| 803 | WHERE REFERENCED_TABLE_SCHEMA = DATABASE() |
|
| 804 | AND REFERENCED_TABLE_NAME IS NOT NULL |
|
| 805 | AND TABLE_NAME = '%s' |
|
| 806 | AND COLUMN_NAME = '%s' |
|
| 807 | ORDER BY POSITION_IN_UNIQUE_CONSTRAINT", |
|
| 808 | $tableName, |
|
| 809 | $column |
|
| 810 | )); |
|
| 811 | ||
| 812 | foreach ($rows as $row) { |
|
| 813 | $instructions->merge($this->getDropForeignKeyInstructions($tableName, $row['CONSTRAINT_NAME'])); |
|
| 814 | } |
|
| 815 | } |
|
| 816 | ||
| 817 | if (empty($instructions->getAlterParts())) { |
|
| 818 | throw new \InvalidArgumentException(sprintf( |
|