Code Duplication    Length = 12-30 lines in 2 locations

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

@@ 484-495 (lines=12) @@
481
     * @param string $tableName Table Name
482
     * @return array
483
     */
484
    protected function getIndexes($tableName)
485
    {
486
        $indexes = [];
487
        $rows = $this->fetchAll(sprintf('SHOW INDEXES FROM %s', $this->quoteTableName($tableName)));
488
        foreach ($rows as $row) {
489
            if (!isset($indexes[$row['Key_name']])) {
490
                $indexes[$row['Key_name']] = ['columns' => []];
491
            }
492
            $indexes[$row['Key_name']]['columns'][] = strtolower($row['Column_name']);
493
        }
494
        return $indexes;
495
    }
496
497
    /**
498
     * {@inheritdoc}

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

@@ 494-523 (lines=30) @@
491
     * @param string $tableName Table Name
492
     * @return array
493
     */
494
    protected function getIndexes($tableName)
495
    {
496
        $indexes = [];
497
        $sql = "SELECT
498
            i.relname AS index_name,
499
            a.attname AS column_name
500
        FROM
501
            pg_class t,
502
            pg_class i,
503
            pg_index ix,
504
            pg_attribute a
505
        WHERE
506
            t.oid = ix.indrelid
507
            AND i.oid = ix.indexrelid
508
            AND a.attrelid = t.oid
509
            AND a.attnum = ANY(ix.indkey)
510
            AND t.relkind = 'r'
511
            AND t.relname = '$tableName'
512
        ORDER BY
513
            t.relname,
514
            i.relname;";
515
        $rows = $this->fetchAll($sql);
516
        foreach ($rows as $row) {
517
            if (!isset($indexes[$row['index_name']])) {
518
                $indexes[$row['index_name']] = ['columns' => []];
519
            }
520
            $indexes[$row['index_name']]['columns'][] = strtolower($row['column_name']);
521
        }
522
        return $indexes;
523
    }
524
525
    /**
526
     * {@inheritdoc}