Code Duplication    Length = 23-24 lines in 2 locations

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

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

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

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