Code Duplication    Length = 23-24 lines in 2 locations

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

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

@@ 726-748 (lines=23) @@
723
     * @param string $tableName Table Name
724
     * @return array
725
     */
726
    public function getPrimaryKey($tableName)
727
    {
728
        $rows = $this->fetchAll(sprintf(
729
            "SELECT
730
                k.constraint_name,
731
                k.column_name
732
            FROM information_schema.table_constraints t
733
            JOIN information_schema.key_column_usage k
734
                USING(constraint_name,table_name)
735
            WHERE t.constraint_type='PRIMARY KEY'
736
                AND t.table_name='%s'",
737
            $tableName
738
        ));
739
740
        $primaryKey = [
741
            'columns' => [],
742
        ];
743
        foreach ($rows as $row) {
744
            $primaryKey['constraint'] = $row['constraint_name'];
745
            $primaryKey['columns'][] = $row['column_name'];
746
        }
747
748
        return $primaryKey;
749
    }
750
751
    /**