Code Duplication    Length = 23-24 lines in 2 locations

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

@@ 686-708 (lines=23) @@
683
     * @param string $tableName Table Name
684
     * @return array
685
     */
686
    public function getPrimaryKey($tableName)
687
    {
688
        $rows = $this->fetchAll(sprintf(
689
            "SELECT
690
                k.constraint_name,
691
                k.column_name
692
            FROM information_schema.table_constraints t
693
            JOIN information_schema.key_column_usage k
694
                USING(constraint_name,table_name)
695
            WHERE t.constraint_type='PRIMARY KEY'
696
                AND t.table_name='%s'",
697
            $tableName
698
        ));
699
700
        $primaryKey = [
701
            'columns' => [],
702
        ];
703
        foreach ($rows as $row) {
704
            $primaryKey['constraint'] = $row['constraint_name'];
705
            $primaryKey['columns'][] = $row['column_name'];
706
        }
707
708
        return $primaryKey;
709
    }
710
711
    /**

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

@@ 838-861 (lines=24) @@
835
     * @param string $tableName Table Name
836
     * @return array
837
     */
838
    public function getPrimaryKey($tableName)
839
    {
840
        $rows = $this->fetchAll(sprintf(
841
            "SELECT
842
                    tc.constraint_name,
843
                    kcu.column_name
844
                FROM information_schema.table_constraints AS tc
845
                JOIN information_schema.key_column_usage AS kcu
846
                    ON tc.constraint_name = kcu.constraint_name
847
                WHERE constraint_type = 'PRIMARY KEY'
848
                    AND tc.table_name = '%s'
849
                ORDER BY kcu.ordinal_position",
850
            $tableName
851
        ));
852
853
        $primaryKey = [
854
            'columns' => [],
855
        ];
856
        foreach ($rows as $row) {
857
            $primaryKey['constraint'] = $row['constraint_name'];
858
            $primaryKey['columns'][] = $row['column_name'];
859
        }
860
861
        return $primaryKey;
862
    }
863
864
    /**