Code Duplication    Length = 18-22 lines in 2 locations

src/Phinx/Db/Adapter/SqlServerAdapter.php 1 location

@@ 991-1012 (lines=22) @@
988
    {
989
        $instructions = new AlterInstructions();
990
991
        foreach ($columns as $column) {
992
            $rows = $this->fetchAll(sprintf(
993
                "SELECT
994
                tc.constraint_name,
995
                tc.table_name, kcu.column_name,
996
                ccu.table_name AS referenced_table_name,
997
                ccu.column_name AS referenced_column_name
998
            FROM
999
                information_schema.table_constraints AS tc
1000
                JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name
1001
                JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name
1002
            WHERE constraint_type = 'FOREIGN KEY' AND tc.table_name = '%s' and ccu.column_name='%s'
1003
            ORDER BY kcu.ordinal_position",
1004
                $tableName,
1005
                $column
1006
            ));
1007
            foreach ($rows as $row) {
1008
                $instructions->merge(
1009
                    $this->getDropForeignKeyInstructions($tableName, $row['constraint_name'])
1010
                );
1011
            }
1012
        }
1013
1014
        return $instructions;
1015
    }

src/Phinx/Db/Adapter/MysqlAdapter.php 1 location

@@ 818-835 (lines=18) @@
815
    {
816
        $instructions = new AlterInstructions();
817
818
        foreach ($columns as $column) {
819
            $rows = $this->fetchAll(sprintf(
820
                "SELECT
821
                    CONSTRAINT_NAME
822
                  FROM information_schema.KEY_COLUMN_USAGE
823
                  WHERE REFERENCED_TABLE_SCHEMA = DATABASE()
824
                    AND REFERENCED_TABLE_NAME IS NOT NULL
825
                    AND TABLE_NAME = '%s'
826
                    AND COLUMN_NAME = '%s'
827
                  ORDER BY POSITION_IN_UNIQUE_CONSTRAINT",
828
                $tableName,
829
                $column
830
            ));
831
832
            foreach ($rows as $row) {
833
                $instructions->merge($this->getDropForeignKeyInstructions($tableName, $row['CONSTRAINT_NAME']));
834
            }
835
        }
836
837
        if (empty($instructions->getAlterParts())) {
838
            throw new InvalidArgumentException(sprintf(