Code Duplication    Length = 18-22 lines in 2 locations

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

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

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

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