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