Code Duplication    Length = 23-24 lines in 2 locations

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

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

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

@@ 861-884 (lines=24) @@
858
     * @param string $tableName Table Name
859
     * @return array
860
     */
861
    public function getPrimaryKey($tableName)
862
    {
863
        $rows = $this->fetchAll(sprintf(
864
            "SELECT
865
                    tc.constraint_name,
866
                    kcu.column_name
867
                FROM information_schema.table_constraints AS tc
868
                JOIN information_schema.key_column_usage AS kcu
869
                    ON tc.constraint_name = kcu.constraint_name
870
                WHERE constraint_type = 'PRIMARY KEY'
871
                    AND tc.table_name = '%s'
872
                ORDER BY kcu.ordinal_position",
873
            $tableName
874
        ));
875
876
        $primaryKey = [
877
            'columns' => [],
878
        ];
879
        foreach ($rows as $row) {
880
            $primaryKey['constraint'] = $row['constraint_name'];
881
            $primaryKey['columns'][] = $row['column_name'];
882
        }
883
884
        return $primaryKey;
885
    }
886
887
    /**