Code Duplication    Length = 26-26 lines in 2 locations

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

@@ 927-952 (lines=26) @@
924
     *
925
     * @return array
926
     */
927
    protected function getForeignKeys($tableName)
928
    {
929
        $foreignKeys = [];
930
        $rows = $this->fetchAll(sprintf(
931
            "SELECT
932
                    tc.constraint_name,
933
                    tc.table_name, kcu.column_name,
934
                    ccu.table_name AS referenced_table_name,
935
                    ccu.column_name AS referenced_column_name
936
                FROM
937
                    information_schema.table_constraints AS tc
938
                    JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name
939
                    JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name
940
                WHERE constraint_type = 'FOREIGN KEY' AND tc.table_name = '%s'
941
                ORDER BY kcu.ordinal_position",
942
            $tableName
943
        ));
944
        foreach ($rows as $row) {
945
            $foreignKeys[$row['constraint_name']]['table'] = $row['table_name'];
946
            $foreignKeys[$row['constraint_name']]['columns'][] = $row['column_name'];
947
            $foreignKeys[$row['constraint_name']]['referenced_table'] = $row['referenced_table_name'];
948
            $foreignKeys[$row['constraint_name']]['referenced_columns'][] = $row['referenced_column_name'];
949
        }
950
951
        return $foreignKeys;
952
    }
953
954
    /**
955
     * @inheritDoc

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

@@ 756-781 (lines=26) @@
753
     *
754
     * @return array
755
     */
756
    protected function getForeignKeys($tableName)
757
    {
758
        $foreignKeys = [];
759
        $rows = $this->fetchAll(sprintf(
760
            "SELECT
761
              CONSTRAINT_NAME,
762
              TABLE_NAME,
763
              COLUMN_NAME,
764
              REFERENCED_TABLE_NAME,
765
              REFERENCED_COLUMN_NAME
766
            FROM information_schema.KEY_COLUMN_USAGE
767
            WHERE REFERENCED_TABLE_SCHEMA = DATABASE()
768
              AND REFERENCED_TABLE_NAME IS NOT NULL
769
              AND TABLE_NAME = '%s'
770
            ORDER BY POSITION_IN_UNIQUE_CONSTRAINT",
771
            $tableName
772
        ));
773
        foreach ($rows as $row) {
774
            $foreignKeys[$row['CONSTRAINT_NAME']]['table'] = $row['TABLE_NAME'];
775
            $foreignKeys[$row['CONSTRAINT_NAME']]['columns'][] = $row['COLUMN_NAME'];
776
            $foreignKeys[$row['CONSTRAINT_NAME']]['referenced_table'] = $row['REFERENCED_TABLE_NAME'];
777
            $foreignKeys[$row['CONSTRAINT_NAME']]['referenced_columns'][] = $row['REFERENCED_COLUMN_NAME'];
778
        }
779
780
        return $foreignKeys;
781
    }
782
783
    /**
784
     * @inheritDoc