Skip to content
Snippets Groups Projects
Unverified Commit b340058e authored by Thomas Flori's avatar Thomas Flori
Browse files

change migrations table to use snake case instead of camel case

Camel case is not supported by some database. Postgres for example
returns every column name in lower case. That does not lead to errors
but even more dangerous it jus silently fails when you try to access
`Migration::$executionTime`.
parent 68acee7a
No related branches found
No related tags found
No related merge requests found
......@@ -16,12 +16,12 @@ class CreateMigrationTable extends AbstractMigration
reverted TIMESTAMP,
status CHARACTER VARYING (16) NOT NULL DEFAULT 'done',
statements TEXT,
executionTime DOUBLE PRECISION,
execution_time DOUBLE PRECISION,
PRIMARY KEY (file)
)");
$this->exec("CREATE INDEX {$table}_executed_index ON {$table} (executed)");
$this->exec("CREATE INDEX {$table}_status_index ON {$table} (status)");
$this->exec("CREATE INDEX {$table}_executionTime_index ON {$table} (executionTime)");
$this->exec("CREATE INDEX {$table}_execution_time_index ON {$table} (execution_time)");
}
/** @codeCoverageIgnore */
......
......@@ -283,7 +283,7 @@ class Migrations
foreach ($migrations as $migration) {
$this->progress->beforeMigration($migration);
$this->statements = $migration->statements;
$start = microtime(true) - $migration->executionTime;
$start = microtime(true) - $migration->execution_time;
try {
$this->db->beginTransaction();
$class = self::internalClass($migration->file) ??
......@@ -367,7 +367,7 @@ class Migrations
$migration->statements = $this->statements;
$migration->status = $status;
$migration->executionTime = $executionTime;
$migration->execution_time = $executionTime;
if (!$exists) {
$this->db->prepare("INSERT INTO {$table}
......@@ -378,7 +378,7 @@ class Migrations
$migration->executed->format('c'),
$migration->status,
json_encode($migration->statements),
$migration->executionTime
$migration->execution_time
]);
} else {
$this->db->prepare("UPDATE {$table} SET
......@@ -389,7 +389,7 @@ class Migrations
$migration->reverted ? $migration->reverted->format('c') : null,
$migration->status,
json_encode($migration->statements),
$migration->executionTime,
$migration->execution_time,
$migration->file
]);
}
......
......@@ -23,7 +23,7 @@ class Migration
public $statements = [];
/** @var double */
public $executionTime;
public $execution_time;
public function __construct()
{
......
......@@ -35,7 +35,7 @@ class CreateMigrationTableTest extends TestCase
->with(m::pattern('/create index.* on migrations\s*\(\s*status\s*\)/i'))
->once();
$adapter->shouldHaveReceived('exec')
->with(m::pattern('/create index.* on migrations\s*\(\s*executionTime\s*\)/i'))
->with(m::pattern('/create index.* on migrations\s*\(\s*execution_time\s*\)/i'))
->once();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment