Code Duplication    Length = 12-30 lines in 2 locations

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

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

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

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