Code Duplication    Length = 23-24 lines in 2 locations

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

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

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

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