Code Duplication    Length = 23-24 lines in 2 locations

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

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

@@ 708-730 (lines=23) @@
705
     * @param string $tableName Table Name
706
     * @return array
707
     */
708
    public function getPrimaryKey($tableName)
709
    {
710
        $rows = $this->fetchAll(sprintf(
711
            "SELECT
712
                k.constraint_name,
713
                k.column_name
714
            FROM information_schema.table_constraints t
715
            JOIN information_schema.key_column_usage k
716
                USING(constraint_name,table_name)
717
            WHERE t.constraint_type='PRIMARY KEY'
718
                AND t.table_name='%s'",
719
            $tableName
720
        ));
721
722
        $primaryKey = [
723
            'columns' => [],
724
        ];
725
        foreach ($rows as $row) {
726
            $primaryKey['constraint'] = $row['constraint_name'];
727
            $primaryKey['columns'][] = $row['column_name'];
728
        }
729
730
        return $primaryKey;
731
    }
732
733
    /**