Skip to content

Commit

Permalink
Merge pull request #2019 from codeigniter4/sqlitedropindex
Browse files Browse the repository at this point in the history
SQLite and Mysql driver additional tests and migration runner test fixes
  • Loading branch information
lonnieezell authored May 21, 2019
2 parents fa575f9 + 7f93048 commit d478c94
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 162 deletions.
4 changes: 2 additions & 2 deletions system/Database/MigrationRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,15 @@ public function version(string $targetVersion, string $namespace = null, string
$this->checkMigrations($migrations, $method, $targetVersion);

// loop migration for each namespace (module)

$migrationStatus = false;
foreach ($migrations as $version => $migration)
{
// Only include migrations within the scoop
// Only include migrations within the scope
if (($method === 'up' && $version > $currentVersion && $version <= $targetVersion) || ( $method === 'down' && $version <= $currentVersion && $version > $targetVersion))
{
$migrationStatus = false;
include_once $migration->path;

// Get namespaced class name
$class = $this->namespace . '\Database\Migrations\Migration_' . ($migration->name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,35 @@ public function up()

// User Table
$this->forge->addField([
'id' => [
'id' => [
'type' => 'INTEGER',
'constraint' => 3,
$unique_or_auto => true,
],
'name' => [
'name' => [
'type' => 'VARCHAR',
'constraint' => 80,
],
'email' => [
'email' => [
'type' => 'VARCHAR',
'constraint' => 100,
],
'country' => [
'country' => [
'type' => 'VARCHAR',
'constraint' => 40,
],
'deleted' => [
'deleted' => [
'type' => 'TINYINT',
'constraint' => 1,
'default' => '0',
],
'created_at' => [
'type' => 'DATETIME',
'null' => true,
'type' => 'DATETIME',
'null' => true,
],
'updated_at' => [
'type' => 'DATETIME',
'null' => true,
'type' => 'DATETIME',
'null' => true,
],
]);
$this->forge->addKey('id', true);
Expand All @@ -58,17 +58,17 @@ public function up()
'type' => 'TEXT',
'null' => true,
],
'deleted' => [
'deleted' => [
'type' => 'TINYINT',
'constraint' => 1,
'default' => '0',
],
'created_at' => [
'created_at' => [
'type' => 'INTEGER',
'constraint' => 11,
'null' => true,
],
'updated_at' => [
'updated_at' => [
'type' => 'INTEGER',
'constraint' => 11,
'null' => true,
Expand All @@ -95,22 +95,22 @@ public function up()

// Empty Table
$this->forge->addField([
'id' => [
'id' => [
'type' => 'INTEGER',
'constraint' => 3,
$unique_or_auto => true,
],
'name' => [
'name' => [
'type' => 'VARCHAR',
'constraint' => 40,
],
'created_at' => [
'type' => 'DATE',
'null' => true,
'type' => 'DATE',
'null' => true,
],
'updated_at' => [
'type' => 'DATE',
'null' => true,
'type' => 'DATE',
'null' => true,
],
]);
$this->forge->addKey('id', true);
Expand All @@ -137,11 +137,11 @@ public function up()

public function down()
{
$this->forge->dropTable('user');
$this->forge->dropTable('job');
$this->forge->dropTable('misc');
$this->forge->dropTable('empty');
$this->forge->dropTable('secondary');
$this->forge->dropTable('user', true);
$this->forge->dropTable('job', true);
$this->forge->dropTable('misc', true);
$this->forge->dropTable('empty', true);
$this->forge->dropTable('secondary', true);
}

//--------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ public function up()

public function down()
{
$this->forge->dropTable('foo');
$this->forge->dropTable('foo', true);
}
}
Loading

0 comments on commit d478c94

Please sign in to comment.