24 lines
917 B
PHP
24 lines
917 B
PHP
<?php
|
|
use Index\Data\IDbConnection;
|
|
use Index\Data\Migration\IDbMigration;
|
|
|
|
final class InitialStructure_20231106_004121 implements IDbMigration {
|
|
public function migrate(IDbConnection $conn): void {
|
|
$existingTables = [];
|
|
$result = $conn->query('SHOW TABLES');
|
|
while($result->next())
|
|
$existingTables[] = $result->getString(0);
|
|
|
|
if(!in_array('exchange-rates', $existingTables))
|
|
$conn->execute('
|
|
CREATE TABLE `exchange-rates` (
|
|
rate_from BINARY(3) NOT NULL,
|
|
rate_to BINARY(3) NOT NULL,
|
|
rate_value DECIMAL(20,6) NOT NULL,
|
|
rate_stored TIMESTAMP NOT NULL DEFAULT current_timestamp(),
|
|
PRIMARY KEY (rate_from, rate_to),
|
|
KEY rate_stored (rate_stored)
|
|
) ENGINE=InnoDB COLLATE="utf8mb4_bin"
|
|
');
|
|
}
|
|
}
|