Code Duplication    Length = 12-30 lines in 2 locations

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

@@ 468-479 (lines=12) @@
465
     * @param string $tableName Table Name
466
     * @return array
467
     */
468
    protected function getIndexes($tableName)
469
    {
470
        $indexes = [];
471
        $rows = $this->fetchAll(sprintf('SHOW INDEXES FROM %s', $this->quoteTableName($tableName)));
472
        foreach ($rows as $row) {
473
            if (!isset($indexes[$row['Key_name']])) {
474
                $indexes[$row['Key_name']] = ['columns' => []];
475
            }
476
            $indexes[$row['Key_name']]['columns'][] = strtolower($row['Column_name']);
477
        }
478
        return $indexes;
479
    }
480
481
    /**
482
     * {@inheritdoc}

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

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