Skip to content

Commit 26ff0bf

Browse files
author
Sartor
committed
Invalid date (1970-01-01) fix in migration table
1 parent 4ac95e4 commit 26ff0bf

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

console/controllers/MigrateController.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,25 +122,25 @@ protected function getMigrationHistory($limit)
122122
*/
123123
protected function addMigrationHistory($version)
124124
{
125-
$command = $this->db->createCommand();
126-
$command->insert($this->migrationTable, [
127-
'version' => $version,
128-
'apply_time' => time(),
129-
'is_deleted' => 0
130-
])->execute();
125+
$this->insertHistory($version);
131126
}
132127

133128
/**
134129
* @inheritdoc
135130
*/
136131
protected function removeMigrationHistory($version)
137132
{
138-
$command = $this->db->createCommand();
139-
$command->insert($this->migrationTable, [
133+
$this->insertHistory($version, true);
134+
}
135+
136+
private function insertHistory(string $version, bool $isDelete = false): void
137+
{
138+
$time = time();
139+
$this->db->createCommand()->insert($this->migrationTable, [
140140
'version' => $version,
141-
'apply_time' => time(),
142-
'is_deleted' => 1
141+
'date' => date('Y-m-d', $time),
142+
'apply_time' => $time,
143+
'is_deleted' => (int) $isDelete
143144
])->execute();
144145
}
145-
146146
}

0 commit comments

Comments
 (0)