Code Duplication    Length = 23-24 lines in 2 locations

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

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

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

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