Code Duplication    Length = 23-24 lines in 2 locations

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
    /**

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

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