Code Duplication    Length = 26-26 lines in 2 locations

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

@@ 767-792 (lines=26) @@
764
     * @param string $tableName Table Name
765
     * @return array
766
     */
767
    protected function getForeignKeys($tableName)
768
    {
769
        $foreignKeys = [];
770
        $rows = $this->fetchAll(sprintf(
771
            "SELECT
772
              CONSTRAINT_NAME,
773
              TABLE_NAME,
774
              COLUMN_NAME,
775
              REFERENCED_TABLE_NAME,
776
              REFERENCED_COLUMN_NAME
777
            FROM information_schema.KEY_COLUMN_USAGE
778
            WHERE REFERENCED_TABLE_SCHEMA = DATABASE()
779
              AND REFERENCED_TABLE_NAME IS NOT NULL
780
              AND TABLE_NAME = '%s'
781
            ORDER BY POSITION_IN_UNIQUE_CONSTRAINT",
782
            $tableName
783
        ));
784
        foreach ($rows as $row) {
785
            $foreignKeys[$row['CONSTRAINT_NAME']]['table'] = $row['TABLE_NAME'];
786
            $foreignKeys[$row['CONSTRAINT_NAME']]['columns'][] = $row['COLUMN_NAME'];
787
            $foreignKeys[$row['CONSTRAINT_NAME']]['referenced_table'] = $row['REFERENCED_TABLE_NAME'];
788
            $foreignKeys[$row['CONSTRAINT_NAME']]['referenced_columns'][] = $row['REFERENCED_COLUMN_NAME'];
789
        }
790
791
        return $foreignKeys;
792
    }
793
794
    /**
795
     * {@inheritdoc}

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

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