35761-vm/db/migrations/002_create_candlestick_data_table.php
Flatlogic Bot ffa84da26a V.1.14
2025-11-15 10:49:49 +00:00

32 lines
1.1 KiB
PHP

<?php
require_once __DIR__ . '/../config.php';
try {
$db = db();
$sql = <<<SQL
CREATE TABLE IF NOT EXISTS candlestick_data (
id INT AUTO_INCREMENT PRIMARY KEY,
symbol VARCHAR(20) NOT NULL,
exchange VARCHAR(50) NOT NULL,
interval_time VARCHAR(10) NOT NULL,
open_time BIGINT NOT NULL,
open_price DECIMAL(20, 8) NOT NULL,
high_price DECIMAL(20, 8) NOT NULL,
low_price DECIMAL(20, 8) NOT NULL,
close_price DECIMAL(20, 8) NOT NULL,
volume DECIMAL(20, 8) NOT NULL,
close_time BIGINT NOT NULL,
quote_asset_volume DECIMAL(20, 8),
number_of_trades INT,
taker_buy_base_asset_volume DECIMAL(20, 8),
taker_buy_quote_asset_volume DECIMAL(20, 8),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UNIQUE KEY `symbol_exchange_interval_time_open_time` (`symbol`, `exchange`, `interval_time`, `open_time`)
);
SQL;
$db->exec($sql);
echo "Migration 002 successful: candlestick_data table created or already exists." . PHP_EOL;
} catch (PDOException $e) {
die("Migration 002 failed: " . $e->getMessage() . PHP_EOL);
}