Code Duplication    Length = 18-22 lines in 2 locations

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

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

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
    }