55 lines
2.2 KiB
SQL
55 lines
2.2 KiB
SQL
CREATE TABLE IF NOT EXISTS system_config (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
config_key VARCHAR(100) UNIQUE NOT NULL,
|
|
config_value TEXT,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS cryptocurrencies (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
symbol VARCHAR(20) UNIQUE NOT NULL,
|
|
name VARCHAR(100) NOT NULL,
|
|
icon_url VARCHAR(255),
|
|
current_price DECIMAL(30, 10) DEFAULT 0,
|
|
change_24h DECIMAL(10, 4) DEFAULT 0,
|
|
high_24h DECIMAL(30, 10) DEFAULT 0,
|
|
low_24h DECIMAL(30, 10) DEFAULT 0,
|
|
volume_24h DECIMAL(30, 10) DEFAULT 0,
|
|
is_active TINYINT(1) DEFAULT 1,
|
|
sort_order INT DEFAULT 0,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS price_controls (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
symbol VARCHAR(20) NOT NULL,
|
|
target_price DECIMAL(30, 10),
|
|
type ENUM('spike', 'target', 'win_loss') DEFAULT 'target',
|
|
duration INT DEFAULT 0, -- in seconds
|
|
is_active TINYINT(1) DEFAULT 0,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS users (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
username VARCHAR(100) UNIQUE NOT NULL,
|
|
email VARCHAR(255) UNIQUE NOT NULL,
|
|
password_hash VARCHAR(255) NOT NULL,
|
|
balance_usdt DECIMAL(30, 10) DEFAULT 0,
|
|
win_loss_control ENUM('random', 'always_win', 'always_loss') DEFAULT 'random',
|
|
is_admin TINYINT(1) DEFAULT 0,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
-- Insert some default data
|
|
INSERT IGNORE INTO system_config (config_key, config_value) VALUES
|
|
('site_name', 'OKX Clone'),
|
|
('theme_color', '#0b0e11'),
|
|
('announcement', 'Welcome to our professional trading platform!');
|
|
|
|
INSERT IGNORE INTO cryptocurrencies (symbol, name, icon_url, current_price, change_24h, high_24h, low_24h, volume_24h) VALUES
|
|
('BTC', 'Bitcoin', 'https://cryptologos.cc/logos/bitcoin-btc-logo.png', 45231.50, 2.45, 46120.00, 44800.00, 1250000000),
|
|
('ETH', 'Ethereum', 'https://cryptologos.cc/logos/ethereum-eth-logo.png', 2450.20, -1.20, 2510.00, 2400.00, 850000000),
|
|
('SOL', 'Solana', 'https://cryptologos.cc/logos/solana-sol-logo.png', 98.45, 5.60, 102.00, 92.00, 450000000);
|