This repository has been archived on 2024-08-28. You can view files and clone it, but cannot push or open issues or pull requests.
satori-services/database/2023_11_06_004121_initial_structure.php

25 lines
917 B
PHP
Raw Normal View History

2023-11-06 00:45:15 +00:00
<?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"
');
}
}