-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdb.sql
More file actions
291 lines (269 loc) · 17.4 KB
/
db.sql
File metadata and controls
291 lines (269 loc) · 17.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
-- ════════════════════════════════════════════════════════════
-- GoldOSRS — Full Database Schema
-- MySQL 8.0+ (IONOS shared hosting)
-- Import: phpMyAdmin → your database → Import → select this file
-- ════════════════════════════════════════════════════════════
SET FOREIGN_KEY_CHECKS = 0;
SET SQL_MODE = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION";
SET time_zone = "+00:00";
-- ── Users ─────────────────────────────────────────────────────────────────────
CREATE TABLE IF NOT EXISTS `users` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`username` VARCHAR(32) NOT NULL UNIQUE,
`email` VARCHAR(255) NOT NULL UNIQUE,
`password` VARCHAR(255) NOT NULL,
`balance_osrs` BIGINT DEFAULT 0 COMMENT 'GP millions',
`balance_rs3` BIGINT DEFAULT 0,
`role` ENUM('user','admin') DEFAULT 'user',
`btc_deposit_address` VARCHAR(100) DEFAULT NULL,
`referral_code` VARCHAR(16) DEFAULT NULL,
`referred_by` INT DEFAULT NULL,
`email_verified` TINYINT(1) DEFAULT 0,
`verification_token` VARCHAR(64) DEFAULT NULL,
`reset_token` VARCHAR(64) DEFAULT NULL,
`reset_expires` DATETIME DEFAULT NULL,
`login_streak` INT DEFAULT 0,
`last_login` DATE DEFAULT NULL,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
KEY `idx_email` (`email`),
KEY `idx_username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- ── Orders ────────────────────────────────────────────────────────────────────
CREATE TABLE IF NOT EXISTS `orders` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`user_id` INT DEFAULT NULL,
`guest_email` VARCHAR(255) DEFAULT NULL,
`guest_rsn` VARCHAR(50) DEFAULT NULL,
`type` ENUM('buy','sell','swap','service') NOT NULL,
`service_type` VARCHAR(100) DEFAULT NULL,
`game` ENUM('osrs','rs3') DEFAULT 'osrs',
`amount` BIGINT DEFAULT 0 COMMENT 'GP millions',
`price_usd` DECIMAL(10,2) DEFAULT 0,
`btc_address` VARCHAR(100) DEFAULT NULL,
`btc_amount` DECIMAL(16,8) DEFAULT NULL,
`btc_txid` VARCHAR(100) DEFAULT NULL,
`payment_method` ENUM('crypto','card','paypal') DEFAULT 'crypto',
`rsn` VARCHAR(50) DEFAULT NULL,
`trade_method` ENUM('face_to_face','grand_exchange','chest') DEFAULT 'face_to_face',
`details` TEXT DEFAULT NULL,
`status` ENUM('pending','paid','processing','completed','cancelled','refunded') DEFAULT 'pending',
`admin_notes` TEXT DEFAULT NULL,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`paid_at` TIMESTAMP NULL DEFAULT NULL,
`completed_at` TIMESTAMP NULL DEFAULT NULL,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE SET NULL,
KEY `idx_status` (`status`),
KEY `idx_user` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- ── Chat Sessions ─────────────────────────────────────────────────────────────
CREATE TABLE IF NOT EXISTS `chat_sessions` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`user_id` INT DEFAULT NULL,
`guest_name` VARCHAR(50) DEFAULT 'Guest',
`guest_email` VARCHAR(255) DEFAULT NULL,
`ip` VARCHAR(45) DEFAULT NULL,
`status` ENUM('open','closed') DEFAULT 'open',
`discord_thread_id` VARCHAR(100) DEFAULT NULL,
`order_id` INT DEFAULT NULL,
`last_activity` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE SET NULL,
KEY `idx_status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- ── Chat Messages ─────────────────────────────────────────────────────────────
CREATE TABLE IF NOT EXISTS `chat_messages` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`session_id` INT NOT NULL,
`sender` ENUM('user','admin','discord') NOT NULL,
`sender_name` VARCHAR(50) DEFAULT NULL,
`message` TEXT NOT NULL,
`read_by_admin` TINYINT(1) DEFAULT 0,
`read_by_user` TINYINT(1) DEFAULT 0,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (`session_id`) REFERENCES `chat_sessions`(`id`) ON DELETE CASCADE,
KEY `idx_session` (`session_id`),
KEY `idx_created` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- ── Games (Provably Fair Gambling) ────────────────────────────────────────────
CREATE TABLE IF NOT EXISTS `games` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`user_id` INT NOT NULL,
`game_type` ENUM('dice','roulette','coinflip','blackjack','highlow','rs3dice') NOT NULL,
`bet` BIGINT NOT NULL COMMENT 'GP millions',
`multiplier` DECIMAL(8,2) DEFAULT 1.00,
`result` VARCHAR(255) DEFAULT NULL,
`win_amount` BIGINT DEFAULT 0,
`won` TINYINT(1) DEFAULT 0,
`server_seed` VARCHAR(64) DEFAULT NULL,
`server_hash` VARCHAR(64) DEFAULT NULL,
`client_seed` VARCHAR(64) DEFAULT NULL,
`nonce` INT DEFAULT 0,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE,
KEY `idx_user` (`user_id`),
KEY `idx_type` (`game_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- ── Toasts ────────────────────────────────────────────────────────────────────
-- username column included here natively (no ALTER TABLE needed)
CREATE TABLE IF NOT EXISTS `toasts` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`type` ENUM('real','simulated') DEFAULT 'simulated',
`username` VARCHAR(50) DEFAULT NULL,
`content` VARCHAR(255) NOT NULL,
`shown` TINYINT(1) DEFAULT 0,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
KEY `idx_shown` (`shown`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- ── Prices ────────────────────────────────────────────────────────────────────
CREATE TABLE IF NOT EXISTS `prices` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`key` VARCHAR(50) NOT NULL UNIQUE,
`value` DECIMAL(10,4) NOT NULL,
`label` VARCHAR(100) DEFAULT NULL,
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- ── Config ────────────────────────────────────────────────────────────────────
CREATE TABLE IF NOT EXISTS `config` (
`key` VARCHAR(100) PRIMARY KEY,
`value` TEXT NOT NULL,
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- ── Settings (required by core.php setting() function) ────────────────────────
CREATE TABLE IF NOT EXISTS `settings` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`key` VARCHAR(100) NOT NULL UNIQUE,
`value` TEXT NOT NULL DEFAULT '',
`label` VARCHAR(200) DEFAULT NULL,
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- ── Deposits ──────────────────────────────────────────────────────────────────
CREATE TABLE IF NOT EXISTS `deposits` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`user_id` INT NOT NULL,
`currency` ENUM('BTC','ETH','LTC') DEFAULT 'BTC',
`address` VARCHAR(100) NOT NULL,
`amount_crypto` DECIMAL(16,8) DEFAULT NULL,
`amount_usd` DECIMAL(10,2) DEFAULT NULL,
`gp_credited` BIGINT DEFAULT 0,
`txid` VARCHAR(100) DEFAULT NULL,
`confirmations` INT DEFAULT 0,
`status` ENUM('pending','confirmed','credited') DEFAULT 'pending',
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`confirmed_at` TIMESTAMP NULL DEFAULT NULL,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE,
KEY `idx_address` (`address`),
KEY `idx_status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- ── Withdrawals ───────────────────────────────────────────────────────────────
CREATE TABLE IF NOT EXISTS `withdrawals` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`user_id` INT NOT NULL,
`game` ENUM('osrs','rs3') DEFAULT 'osrs',
`amount` BIGINT NOT NULL COMMENT 'GP millions',
`rsn` VARCHAR(50) NOT NULL,
`trade_method` VARCHAR(50) DEFAULT 'face_to_face',
`status` ENUM('pending','processing','completed','rejected') DEFAULT 'pending',
`admin_notes` TEXT DEFAULT NULL,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- ── Admin Log ─────────────────────────────────────────────────────────────────
CREATE TABLE IF NOT EXISTS `admin_log` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`admin_id` INT DEFAULT NULL,
`action` VARCHAR(255) NOT NULL,
`target_type` VARCHAR(50) DEFAULT NULL,
`target_id` INT DEFAULT NULL,
`details` TEXT DEFAULT NULL,
`ip` VARCHAR(45) DEFAULT NULL,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- ── Raffle Prizes ──────────────────────────────────────────────────────────────
CREATE TABLE IF NOT EXISTS `raffle_prizes` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`name` VARCHAR(100) NOT NULL,
`value` BIGINT NOT NULL COMMENT 'Prize value in GP millions',
`added_date` DATE NOT NULL,
`active` TINYINT(1) DEFAULT 1,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
KEY `idx_active` (`active`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- ════════════════════════════════════════════════════════════
-- SEED DATA
-- ════════════════════════════════════════════════════════════
-- ── Default Prices ────────────────────────────────────────────────────────────
INSERT INTO `prices` (`key`, `value`, `label`) VALUES
('osrs_crypto', 0.26, 'OSRS Gold - Crypto (per M)'),
('osrs_card', 0.29, 'OSRS Gold - Card (per M)'),
('osrs_bulk', 0.24, 'OSRS Gold - Bulk 1B+ (per M)'),
('rs3_crypto', 0.05, 'RS3 Gold - Crypto (per M)'),
('rs3_card', 0.06, 'RS3 Gold - Card (per M)'),
('rs3_bulk', 0.04, 'RS3 Gold - Bulk 5B+ (per M)'),
('sell_osrs', 0.20, 'Sell OSRS Gold - Crypto (per M)'),
('sell_rs3', 0.04, 'Sell RS3 Gold (per M)'),
('swap_rate', 5.80, 'OSRS to RS3 swap ratio')
ON DUPLICATE KEY UPDATE `value` = VALUES(`value`);
-- ── Default Config ────────────────────────────────────────────────────────────
INSERT INTO `config` (`key`, `value`) VALUES
('gambling_enabled', '1'),
('min_bet_osrs', '5'),
('max_bet_osrs', '2000'),
('house_edge_dice', '3'),
('house_edge_coinflip', '5'),
('house_edge_blackjack', '2'),
('site_live', '1')
ON DUPLICATE KEY UPDATE `value` = VALUES(`value`);
-- ── Default Settings ─────────────────────────────────────────────────────────
INSERT INTO `settings` (`key`, `value`, `label`) VALUES
('site_name', 'GoldOSRS', 'Site Name'),
('site_url', 'https://goldosrs.com', 'Site URL'),
('site_email', 'support@goldosrs.com', 'Support Email'),
('site_live', '1', 'Site Live (0=maintenance)'),
('discord_webhook', '', 'Discord Webhook URL'),
('btc_address', '', 'Static BTC Address'),
('osrs_crypto', '0.26', 'OSRS Crypto Rate (per M)'),
('osrs_card', '0.29', 'OSRS Card Rate (per M)'),
('osrs_bulk', '0.24', 'OSRS Bulk Rate (per M)'),
('rs3_crypto', '0.05', 'RS3 Crypto Rate (per M)'),
('rs3_card', '0.06', 'RS3 Card Rate (per M)'),
('rs3_bulk', '0.04', 'RS3 Bulk Rate (per M)'),
('sell_osrs', '0.20', 'Buy OSRS Rate (per M)'),
('sell_rs3', '0.04', 'Buy RS3 Rate (per M)'),
('swap_rate', '5.80', 'OSRS to RS3 Swap Ratio'),
('gambling_enabled', '1', 'Gambling Enabled'),
('min_bet', '5', 'Min Bet (M GP)'),
('max_bet', '2000', 'Max Bet (M GP)'),
('house_edge_dice', '3', 'Dice House Edge %'),
('house_edge_coinflip', '5', 'Coinflip House Edge %'),
('house_edge_blackjack', '2', 'Blackjack House Edge %'),
('toasts_enabled', '1', 'Toast Notifications'),
('admin_email', 'admin@goldosrs.com', 'Admin Email')
ON DUPLICATE KEY UPDATE `value` = VALUES(`value`);
-- ── Default Admin Account ─────────────────────────────────────────────────────
-- Default password: password ← CHANGE THIS immediately after import
-- To generate a new hash in PHP:
-- echo password_hash('yournewpassword', PASSWORD_BCRYPT);
INSERT IGNORE INTO `users`
(`username`, `email`, `password`, `role`, `email_verified`)
VALUES
('admin', 'admin@goldosrs.com',
'$2y$12$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi',
'admin', 1);
-- ── Seed Raffle Prizes ────────────────────────────────────────────────────────
INSERT INTO `raffle_prizes` (`name`, `value`, `added_date`) VALUES
('100M OSRS Gold', 100, CURDATE()),
('500M OSRS Gold', 500, CURDATE()),
('1B OSRS Gold', 1000, CURDATE()),
('Inferno Cape Service', 5000, CURDATE()),
('500M RS3 Gold', 500, CURDATE()),
('Quest Cape Service', 2000, CURDATE());
-- ── Seed Toasts ───────────────────────────────────────────────────────────────
INSERT INTO `toasts` (`type`, `username`, `content`) VALUES
('simulated', 'GoldOSRS', '🪙 Someone from UK just bought 500M OSRS Gold'),
('simulated', 'GoldOSRS', '⚔️ Dragon_Pro just ordered Inferno Cape Service'),
('simulated', 'GoldOSRS', '🪙 Someone from US just bought 1B OSRS Gold'),
('simulated', 'GoldOSRS', '🌸 MaxedMain just bought 2B OSRS Gold'),
('simulated', 'GoldOSRS', '⚔️ Someone from AU just ordered Quest Cape Service'),
('simulated', 'GoldOSRS', '🪙 Someone from DE just bought 200M RS3 Gold'),
('simulated', 'GoldOSRS', '⚔️ PvM_Legend just ordered Boss Service - ToB');
SET FOREIGN_KEY_CHECKS = 1;