Code Duplication    Length = 18-22 lines in 2 locations

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

@@ 803-820 (lines=18) @@
800
    {
801
        $instructions = new AlterInstructions();
802
803
        foreach ($columns as $column) {
804
            $rows = $this->fetchAll(sprintf(
805
                "SELECT
806
                    CONSTRAINT_NAME
807
                  FROM information_schema.KEY_COLUMN_USAGE
808
                  WHERE REFERENCED_TABLE_SCHEMA = DATABASE()
809
                    AND REFERENCED_TABLE_NAME IS NOT NULL
810
                    AND TABLE_NAME = '%s'
811
                    AND COLUMN_NAME = '%s'
812
                  ORDER BY POSITION_IN_UNIQUE_CONSTRAINT",
813
                $tableName,
814
                $column
815
            ));
816
817
            foreach ($rows as $row) {
818
                $instructions->merge($this->getDropForeignKeyInstructions($tableName, $row['CONSTRAINT_NAME']));
819
            }
820
        }
821
822
        if (empty($instructions->getAlterParts())) {
823
            throw new \InvalidArgumentException(sprintf(

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

@@ 961-982 (lines=22) @@
958
    {
959
        $instructions = new AlterInstructions();
960
961
        foreach ($columns as $column) {
962
            $rows = $this->fetchAll(sprintf(
963
                "SELECT
964
                tc.constraint_name,
965
                tc.table_name, kcu.column_name,
966
                ccu.table_name AS referenced_table_name,
967
                ccu.column_name AS referenced_column_name
968
            FROM
969
                information_schema.table_constraints AS tc
970
                JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name
971
                JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name
972
            WHERE constraint_type = 'FOREIGN KEY' AND tc.table_name = '%s' and ccu.column_name='%s'
973
            ORDER BY kcu.ordinal_position",
974
                $tableName,
975
                $column
976
            ));
977
            foreach ($rows as $row) {
978
                $instructions->merge(
979
                    $this->getDropForeignKeyInstructions($tableName, $row['constraint_name'])
980
                );
981
            }
982
        }
983
984
        return $instructions;
985
    }