Code Duplication    Length = 18-22 lines in 2 locations

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

@@ 827-844 (lines=18) @@
824
    {
825
        $instructions = new AlterInstructions();
826
827
        foreach ($columns as $column) {
828
            $rows = $this->fetchAll(sprintf(
829
                "SELECT
830
                    CONSTRAINT_NAME
831
                  FROM information_schema.KEY_COLUMN_USAGE
832
                  WHERE REFERENCED_TABLE_SCHEMA = DATABASE()
833
                    AND REFERENCED_TABLE_NAME IS NOT NULL
834
                    AND TABLE_NAME = '%s'
835
                    AND COLUMN_NAME = '%s'
836
                  ORDER BY POSITION_IN_UNIQUE_CONSTRAINT",
837
                $tableName,
838
                $column
839
            ));
840
841
            foreach ($rows as $row) {
842
                $instructions->merge($this->getDropForeignKeyInstructions($tableName, $row['CONSTRAINT_NAME']));
843
            }
844
        }
845
846
        if (empty($instructions->getAlterParts())) {
847
            throw new \InvalidArgumentException(sprintf(

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

@@ 984-1005 (lines=22) @@
981
    {
982
        $instructions = new AlterInstructions();
983
984
        foreach ($columns as $column) {
985
            $rows = $this->fetchAll(sprintf(
986
                "SELECT
987
                tc.constraint_name,
988
                tc.table_name, kcu.column_name,
989
                ccu.table_name AS referenced_table_name,
990
                ccu.column_name AS referenced_column_name
991
            FROM
992
                information_schema.table_constraints AS tc
993
                JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name
994
                JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name
995
            WHERE constraint_type = 'FOREIGN KEY' AND tc.table_name = '%s' and ccu.column_name='%s'
996
            ORDER BY kcu.ordinal_position",
997
                $tableName,
998
                $column
999
            ));
1000
            foreach ($rows as $row) {
1001
                $instructions->merge(
1002
                    $this->getDropForeignKeyInstructions($tableName, $row['constraint_name'])
1003
                );
1004
            }
1005
        }
1006
1007
        return $instructions;
1008
    }