Code Duplication    Length = 18-22 lines in 2 locations

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

@@ 857-878 (lines=22) @@
854
    {
855
        $instructions = new AlterInstructions();
856
857
        foreach ($columns as $column) {
858
            $rows = $this->fetchAll(sprintf(
859
                "SELECT
860
                tc.constraint_name,
861
                tc.table_name, kcu.column_name,
862
                ccu.table_name AS referenced_table_name,
863
                ccu.column_name AS referenced_column_name
864
            FROM
865
                information_schema.table_constraints AS tc
866
                JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name
867
                JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name
868
            WHERE constraint_type = 'FOREIGN KEY' AND tc.table_name = '%s' and ccu.column_name='%s'
869
            ORDER BY kcu.ordinal_position",
870
                $tableName,
871
                $column
872
            ));
873
            foreach ($rows as $row) {
874
                $instructions->merge(
875
                    $this->getDropForeignKeyInstructions($tableName, $row['constraint_name'])
876
                );
877
            }
878
        }
879
880
        return $instructions;
881
    }

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

@@ 676-693 (lines=18) @@
673
    {
674
        $instructions = new AlterInstructions();
675
676
        foreach ($columns as $column) {
677
            $rows = $this->fetchAll(sprintf(
678
                "SELECT
679
                    CONSTRAINT_NAME
680
                  FROM information_schema.KEY_COLUMN_USAGE
681
                  WHERE REFERENCED_TABLE_SCHEMA = DATABASE()
682
                    AND REFERENCED_TABLE_NAME IS NOT NULL
683
                    AND TABLE_NAME = '%s'
684
                    AND COLUMN_NAME = '%s'
685
                  ORDER BY POSITION_IN_UNIQUE_CONSTRAINT",
686
                $tableName,
687
                $column
688
            ));
689
690
            foreach ($rows as $row) {
691
                $instructions->merge($this->getDropForeignKeyInstructions($tableName, $row['CONSTRAINT_NAME']));
692
            }
693
        }
694
695
        if (empty($instructions->getAlterParts())) {
696
            throw new \InvalidArgumentException(sprintf(