Skip to content

Commit

Permalink
Merge pull request #23 from sartor/master
Browse files Browse the repository at this point in the history
Invalid date (1970-01-01) fix in migration table
  • Loading branch information
sartor authored Sep 10, 2020
2 parents 4ac95e4 + 57e6ec0 commit f56d6a2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
22 changes: 11 additions & 11 deletions console/controllers/MigrateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,25 +122,25 @@ protected function getMigrationHistory($limit)
*/
protected function addMigrationHistory($version)
{
$command = $this->db->createCommand();
$command->insert($this->migrationTable, [
'version' => $version,
'apply_time' => time(),
'is_deleted' => 0
])->execute();
$this->insertHistory($version);
}

/**
* @inheritdoc
*/
protected function removeMigrationHistory($version)
{
$command = $this->db->createCommand();
$command->insert($this->migrationTable, [
$this->insertHistory($version, true);
}

private function insertHistory(string $version, bool $isDelete = false): void
{
$time = time();
$this->db->createCommand()->insert($this->migrationTable, [
'version' => $version,
'apply_time' => time(),
'is_deleted' => 1
'date' => date('Y-m-d', $time),
'apply_time' => $time,
'is_deleted' => (int) $isDelete
])->execute();
}

}
14 changes: 7 additions & 7 deletions tests/SchemaBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ public function testDefaultExpression()
$this->assertEquals(1, $createResult);

$expected = [
['default_kind' => 'DEFAULT', 'default_expression' => "CAST(100, 'Int32')"],
['default_kind' => 'DEFAULT', 'default_expression' => "CAST(100, 'Nullable(UInt32)')"],
['default_kind' => 'DEFAULT', 'default_expression' => "CAST('qweasdzxc1', 'Nullable(FixedString(10))')"],
['default_kind' => 'DEFAULT', 'default_expression' => "100"],
['default_kind' => 'DEFAULT', 'default_expression' => "100"],
['default_kind' => 'DEFAULT', 'default_expression' => "'qweasdzxc1'"],
['default_kind' => 'DEFAULT', 'default_expression' => "'str1'"],
['default_kind' => 'DEFAULT', 'default_expression' => "concat('str1', 'str2')"],
['default_kind' => 'DEFAULT', 'default_expression' => "today()"],
Expand All @@ -258,10 +258,10 @@ public function testDefaultValue()
$this->assertEquals(1, $createResult);

$expected = [
['default_kind' => 'DEFAULT', 'default_expression' => "CAST('100', 'Int32')"],
['default_kind' => 'DEFAULT', 'default_expression' => "CAST(100, 'Int32')"],
['default_kind' => 'DEFAULT', 'default_expression' => "CAST(100, 'Nullable(UInt32)')"],
['default_kind' => 'DEFAULT', 'default_expression' => "CAST('qweasdzxc1', 'Nullable(FixedString(10))')"],
['default_kind' => 'DEFAULT', 'default_expression' => "'100'"],
['default_kind' => 'DEFAULT', 'default_expression' => "100"],
['default_kind' => 'DEFAULT', 'default_expression' => "100"],
['default_kind' => 'DEFAULT', 'default_expression' => "'qweasdzxc1'"],
['default_kind' => 'DEFAULT', 'default_expression' => "'str1'"],
];

Expand Down

0 comments on commit f56d6a2

Please sign in to comment.