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

@@ 842-859 (lines=18) @@
839
    {
840
        $instructions = new AlterInstructions();
841
842
        foreach ($columns as $column) {
843
            $rows = $this->fetchAll(sprintf(
844
                "SELECT
845
                    CONSTRAINT_NAME
846
                  FROM information_schema.KEY_COLUMN_USAGE
847
                  WHERE REFERENCED_TABLE_SCHEMA = DATABASE()
848
                    AND REFERENCED_TABLE_NAME IS NOT NULL
849
                    AND TABLE_NAME = '%s'
850
                    AND COLUMN_NAME = '%s'
851
                  ORDER BY POSITION_IN_UNIQUE_CONSTRAINT",
852
                $tableName,
853
                $column
854
            ));
855
856
            foreach ($rows as $row) {
857
                $instructions->merge($this->getDropForeignKeyInstructions($tableName, $row['CONSTRAINT_NAME']));
858
            }
859
        }
860
861
        if (empty($instructions->getAlterParts())) {
862
            throw new InvalidArgumentException(sprintf(