94 lines
4.2 KiB
SQL
94 lines
4.2 KiB
SQL
-- Orders table for Spot trading
|
|
CREATE TABLE IF NOT EXISTS spot_orders (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
user_id INT NOT NULL,
|
|
symbol VARCHAR(20) NOT NULL,
|
|
side ENUM('buy', 'sell') NOT NULL,
|
|
type ENUM('limit', 'market') DEFAULT 'limit',
|
|
price DECIMAL(30, 10),
|
|
amount DECIMAL(30, 10) NOT NULL,
|
|
filled_amount DECIMAL(30, 10) DEFAULT 0,
|
|
status ENUM('open', 'filled', 'cancelled', 'partially_filled') DEFAULT 'open',
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (user_id) REFERENCES users(id)
|
|
);
|
|
|
|
-- Positions table for Perpetual Contracts
|
|
CREATE TABLE IF NOT EXISTS contract_positions (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
user_id INT NOT NULL,
|
|
symbol VARCHAR(20) NOT NULL,
|
|
side ENUM('long', 'short') NOT NULL,
|
|
leverage INT DEFAULT 1,
|
|
entry_price DECIMAL(30, 10) NOT NULL,
|
|
size DECIMAL(30, 10) NOT NULL,
|
|
margin DECIMAL(30, 10) NOT NULL,
|
|
liquidation_price DECIMAL(30, 10),
|
|
unrealized_pnl DECIMAL(30, 10) DEFAULT 0,
|
|
status ENUM('active', 'closed', 'liquidated') DEFAULT 'active',
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
closed_at TIMESTAMP NULL,
|
|
FOREIGN KEY (user_id) REFERENCES users(id)
|
|
);
|
|
|
|
-- Carousel for Landing Page
|
|
CREATE TABLE IF NOT EXISTS carousel (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
image_url VARCHAR(255) NOT NULL,
|
|
title VARCHAR(100),
|
|
description TEXT,
|
|
link_url VARCHAR(255),
|
|
sort_order INT DEFAULT 0,
|
|
is_active TINYINT(1) DEFAULT 1
|
|
);
|
|
|
|
-- Languages Table
|
|
CREATE TABLE IF NOT EXISTS languages (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
code VARCHAR(10) UNIQUE NOT NULL, -- e.g., 'en', 'zh', 'ja', 'ko', 'ru', 'fr', 'es', 'de'
|
|
name VARCHAR(50) NOT NULL,
|
|
is_default TINYINT(1) DEFAULT 0
|
|
);
|
|
|
|
-- Translations Table
|
|
CREATE TABLE IF NOT EXISTS translations (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
lang_code VARCHAR(10) NOT NULL,
|
|
trans_key VARCHAR(255) NOT NULL,
|
|
trans_value TEXT NOT NULL,
|
|
UNIQUE KEY (lang_code, trans_key)
|
|
);
|
|
|
|
-- Update system config for BITCrypto
|
|
UPDATE system_config SET config_value = 'BITCrypto' WHERE config_key = 'site_name';
|
|
|
|
-- Insert Languages
|
|
INSERT IGNORE INTO languages (code, name, is_default) VALUES
|
|
('en', 'English', 1),
|
|
('zh', '简体中文', 0),
|
|
('ja', '日本語', 0),
|
|
('ko', '한국어', 0),
|
|
('ru', 'Русский', 0),
|
|
('fr', 'Français', 0),
|
|
('es', 'Español', 0),
|
|
('de', 'Deutsch', 0);
|
|
|
|
-- Insert Carousel Data (Using placeholder images for now)
|
|
INSERT IGNORE INTO carousel (image_url, title, description, sort_order) VALUES
|
|
('https://images.pexels.com/photos/844124/pexels-photo-844124.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1', 'Global Leading Exchange', 'Trade BTC, ETH and 500+ assets with BITCrypto.', 1),
|
|
('https://images.pexels.com/photos/6770610/pexels-photo-6770610.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1', 'Perpetual Contracts', 'Up to 125x leverage on major pairs.', 2),
|
|
('https://images.pexels.com/photos/6771574/pexels-photo-6771574.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1', 'Secure & Reliable', 'Bank-level security for your digital assets.', 3),
|
|
('https://images.pexels.com/photos/5980860/pexels-photo-5980860.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1', '24/7 Support', 'Our team is here to help you anytime.', 4),
|
|
('https://images.pexels.com/photos/7567443/pexels-photo-7567443.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1', 'Low Trading Fees', 'Enjoy the most competitive fees in the industry.', 5);
|
|
|
|
-- Add more coins
|
|
INSERT IGNORE INTO cryptocurrencies (symbol, name, icon_url, current_price, change_24h) VALUES
|
|
('BNB', 'BNB', 'https://cryptologos.cc/logos/bnb-bnb-logo.png', 312.45, 1.2),
|
|
('XRP', 'XRP', 'https://cryptologos.cc/logos/xrp-xrp-logo.png', 0.52, -0.5),
|
|
('ADA', 'Cardano', 'https://cryptologos.cc/logos/cardano-ada-logo.png', 0.48, 2.3),
|
|
('AVAX', 'Avalanche', 'https://cryptologos.cc/logos/avalanche-avax-logo.png', 35.60, 4.1),
|
|
('DOT', 'Polkadot', 'https://cryptologos.cc/logos/polkadot-new-dot-logo.png', 7.20, -1.8),
|
|
('MATIC', 'Polygon', 'https://cryptologos.cc/logos/polygon-matic-logo.png', 0.85, 0.9),
|
|
('LINK', 'Chainlink', 'https://cryptologos.cc/logos/chainlink-link-logo.png', 18.30, 3.5),
|
|
('DOGE', 'Dogecoin', 'https://cryptologos.cc/logos/dogecoin-doge-logo.png', 0.08, -2.1);
|