• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

codeigniter4 / CodeIgniter4 / 7191045469

13 Dec 2023 05:15AM UTC coverage: 85.233% (-0.004%) from 85.237%
7191045469

push

github

web-flow
fix: migrations not using custom DB connection of migration runner (#8221)

* Add failing test

* Add fix

* Fix setting of group

* Change priority order of migration's db group

7 of 8 new or added lines in 2 files covered. (87.5%)

1 existing line in 1 file now uncovered.

18597 of 21819 relevant lines covered (85.23%)

199.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
/system/Database/Migration.php
1
<?php
2

3
/**
4
 * This file is part of CodeIgniter 4 framework.
5
 *
6
 * (c) CodeIgniter Foundation <admin@codeigniter.com>
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 */
11

12
namespace CodeIgniter\Database;
13

14
use Config\Database;
15

16
/**
17
 * Class Migration
18
 */
19
abstract class Migration
20
{
21
    /**
22
     * The name of the database group to use.
23
     *
24
     * @var string|null
25
     */
26
    protected $DBGroup;
27

28
    /**
29
     * Database Connection instance
30
     *
31
     * @var ConnectionInterface
32
     */
33
    protected $db;
34

35
    /**
36
     * Database Forge instance.
37
     *
38
     * @var Forge
39
     */
40
    protected $forge;
41

42
    public function __construct(?Forge $forge = null)
43
    {
44
        if (isset($this->DBGroup)) {
568✔
45
            $this->forge = Database::forge($this->DBGroup);
1✔
46
        } elseif ($forge !== null) {
568✔
47
            $this->forge = $forge;
568✔
48
        } else {
NEW
49
            $this->forge = Database::forge(config(Database::class)->defaultGroup);
×
50
        }
51

52
        $this->db = $this->forge->getConnection();
568✔
53
    }
54

55
    /**
56
     * Returns the database group name this migration uses.
57
     */
58
    public function getDBGroup(): ?string
59
    {
60
        return $this->DBGroup;
568✔
61
    }
62

63
    /**
64
     * Perform a migration step.
65
     */
66
    abstract public function up();
67

68
    /**
69
     * Revert a migration step.
70
     */
71
    abstract public function down();
72
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc