Skip to content

Commit d478c94

Browse files
authored
Merge pull request #2019 from codeigniter4/sqlitedropindex
SQLite and Mysql driver additional tests and migration runner test fixes
2 parents fa575f9 + 7f93048 commit d478c94

5 files changed

Lines changed: 169 additions & 162 deletions

File tree

system/Database/MigrationRunner.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,15 +254,15 @@ public function version(string $targetVersion, string $namespace = null, string
254254
$this->checkMigrations($migrations, $method, $targetVersion);
255255

256256
// loop migration for each namespace (module)
257-
258257
$migrationStatus = false;
259258
foreach ($migrations as $version => $migration)
260259
{
261-
// Only include migrations within the scoop
260+
// Only include migrations within the scope
262261
if (($method === 'up' && $version > $currentVersion && $version <= $targetVersion) || ( $method === 'down' && $version <= $currentVersion && $version > $targetVersion))
263262
{
264263
$migrationStatus = false;
265264
include_once $migration->path;
265+
266266
// Get namespaced class name
267267
$class = $this->namespace . '\Database\Migrations\Migration_' . ($migration->name);
268268

tests/_support/Database/Migrations/20160428212500_Create_test_tables.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,35 @@ public function up()
99

1010
// User Table
1111
$this->forge->addField([
12-
'id' => [
12+
'id' => [
1313
'type' => 'INTEGER',
1414
'constraint' => 3,
1515
$unique_or_auto => true,
1616
],
17-
'name' => [
17+
'name' => [
1818
'type' => 'VARCHAR',
1919
'constraint' => 80,
2020
],
21-
'email' => [
21+
'email' => [
2222
'type' => 'VARCHAR',
2323
'constraint' => 100,
2424
],
25-
'country' => [
25+
'country' => [
2626
'type' => 'VARCHAR',
2727
'constraint' => 40,
2828
],
29-
'deleted' => [
29+
'deleted' => [
3030
'type' => 'TINYINT',
3131
'constraint' => 1,
3232
'default' => '0',
3333
],
3434
'created_at' => [
35-
'type' => 'DATETIME',
36-
'null' => true,
35+
'type' => 'DATETIME',
36+
'null' => true,
3737
],
3838
'updated_at' => [
39-
'type' => 'DATETIME',
40-
'null' => true,
39+
'type' => 'DATETIME',
40+
'null' => true,
4141
],
4242
]);
4343
$this->forge->addKey('id', true);
@@ -58,17 +58,17 @@ public function up()
5858
'type' => 'TEXT',
5959
'null' => true,
6060
],
61-
'deleted' => [
61+
'deleted' => [
6262
'type' => 'TINYINT',
6363
'constraint' => 1,
6464
'default' => '0',
6565
],
66-
'created_at' => [
66+
'created_at' => [
6767
'type' => 'INTEGER',
6868
'constraint' => 11,
6969
'null' => true,
7070
],
71-
'updated_at' => [
71+
'updated_at' => [
7272
'type' => 'INTEGER',
7373
'constraint' => 11,
7474
'null' => true,
@@ -95,22 +95,22 @@ public function up()
9595

9696
// Empty Table
9797
$this->forge->addField([
98-
'id' => [
98+
'id' => [
9999
'type' => 'INTEGER',
100100
'constraint' => 3,
101101
$unique_or_auto => true,
102102
],
103-
'name' => [
103+
'name' => [
104104
'type' => 'VARCHAR',
105105
'constraint' => 40,
106106
],
107107
'created_at' => [
108-
'type' => 'DATE',
109-
'null' => true,
108+
'type' => 'DATE',
109+
'null' => true,
110110
],
111111
'updated_at' => [
112-
'type' => 'DATE',
113-
'null' => true,
112+
'type' => 'DATE',
113+
'null' => true,
114114
],
115115
]);
116116
$this->forge->addKey('id', true);
@@ -137,11 +137,11 @@ public function up()
137137

138138
public function down()
139139
{
140-
$this->forge->dropTable('user');
141-
$this->forge->dropTable('job');
142-
$this->forge->dropTable('misc');
143-
$this->forge->dropTable('empty');
144-
$this->forge->dropTable('secondary');
140+
$this->forge->dropTable('user', true);
141+
$this->forge->dropTable('job', true);
142+
$this->forge->dropTable('misc', true);
143+
$this->forge->dropTable('empty', true);
144+
$this->forge->dropTable('secondary', true);
145145
}
146146

147147
//--------------------------------------------------------------------

tests/_support/Database/SupportMigrations/001_Some_migration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ public function up()
1919

2020
public function down()
2121
{
22-
$this->forge->dropTable('foo');
22+
$this->forge->dropTable('foo', true);
2323
}
2424
}

0 commit comments

Comments
 (0)