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

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