| 1 | delete from participant_stats;
|
|---|
| 2 | delete from stat_types;
|
|---|
| 3 | delete from match_participants;
|
|---|
| 4 | delete from match_teams;
|
|---|
| 5 | delete from matches;
|
|---|
| 6 | delete from tournament_teams;
|
|---|
| 7 | delete from tournaments;
|
|---|
| 8 | delete from team_memberships;
|
|---|
| 9 | delete from teams;
|
|---|
| 10 | delete from user_achievements;
|
|---|
| 11 | delete from achievements;
|
|---|
| 12 | delete from reviews;
|
|---|
| 13 | delete from notifications;
|
|---|
| 14 | delete from preferences;
|
|---|
| 15 | delete from payments;
|
|---|
| 16 | delete from subscriptions;
|
|---|
| 17 | delete from direct_messages;
|
|---|
| 18 | delete from friendships;
|
|---|
| 19 | delete from linked_accounts;
|
|---|
| 20 | delete from servers;
|
|---|
| 21 | delete from game_modes;
|
|---|
| 22 | delete from game_developers;
|
|---|
| 23 | delete from game_genres;
|
|---|
| 24 | delete from genres;
|
|---|
| 25 | delete from developers;
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 | insert into linked_account_providers (id, name) values
|
|---|
| 29 | (1, 'steam'),
|
|---|
| 30 | (2, 'discord'),
|
|---|
| 31 | (3, 'google'),
|
|---|
| 32 | (4, 'github')
|
|---|
| 33 | on conflict (id) do nothing;
|
|---|
| 34 |
|
|---|
| 35 | insert into friendship_statuses (id, name) values
|
|---|
| 36 | (1, 'pending'),
|
|---|
| 37 | (2, 'accepted'),
|
|---|
| 38 | (3, 'rejected'),
|
|---|
| 39 | (4, 'blocked')
|
|---|
| 40 | on conflict (id) do nothing;
|
|---|
| 41 |
|
|---|
| 42 | insert into subscription_plans (id, name) values
|
|---|
| 43 | (1, 'free'),
|
|---|
| 44 | (2, 'basic'),
|
|---|
| 45 | (3, 'premium'),
|
|---|
| 46 | (4, 'pro')
|
|---|
| 47 | on conflict (id) do nothing;
|
|---|
| 48 |
|
|---|
| 49 | insert into notification_types (id, name) values
|
|---|
| 50 | (1, 'system'),
|
|---|
| 51 | (2, 'friend_request'),
|
|---|
| 52 | (3, 'message'),
|
|---|
| 53 | (4, 'achievement'),
|
|---|
| 54 | (5, 'tournament'),
|
|---|
| 55 | (6, 'subscription')
|
|---|
| 56 | on conflict (id) do nothing;
|
|---|
| 57 |
|
|---|
| 58 | insert into team_member_roles (id, name) values
|
|---|
| 59 | (1, 'member'),
|
|---|
| 60 | (2, 'captain'),
|
|---|
| 61 | (3, 'coach'),
|
|---|
| 62 | (4, 'owner')
|
|---|
| 63 | on conflict (id) do nothing;
|
|---|
| 64 |
|
|---|
| 65 | insert into match_statuses (id, name) values
|
|---|
| 66 | (1, 'scheduled'),
|
|---|
| 67 | (2, 'in_progress'),
|
|---|
| 68 | (3, 'completed'),
|
|---|
| 69 | (4, 'cancelled')
|
|---|
| 70 | on conflict (id) do nothing;
|
|---|
| 71 |
|
|---|
| 72 | insert into participant_results (id, name) values
|
|---|
| 73 | (1, 'win'),
|
|---|
| 74 | (2, 'loss'),
|
|---|
| 75 | (3, 'draw')
|
|---|
| 76 | on conflict (id) do nothing;
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 | insert into locations (id, latitude, longitude, country, city)
|
|---|
| 80 | values (0, 41.998100, 21.426400, 'Unknown', 'Unknown')
|
|---|
| 81 | on conflict (id) do nothing;
|
|---|
| 82 |
|
|---|
| 83 | insert into users (id, username, email, password_hash, location_id, created_at, updated_at)
|
|---|
| 84 | values (
|
|---|
| 85 | 0,
|
|---|
| 86 | 'unknown_user',
|
|---|
| 87 | 'unknown_user@test.com',
|
|---|
| 88 | md5('unknown_user'),
|
|---|
| 89 | 0,
|
|---|
| 90 | current_timestamp,
|
|---|
| 91 | current_timestamp
|
|---|
| 92 | )
|
|---|
| 93 | on conflict (id) do nothing;
|
|---|
| 94 |
|
|---|
| 95 | insert into developers (id, name, country)
|
|---|
| 96 | values (0, 'Unknown Developer', 'Unknown')
|
|---|
| 97 | on conflict (id) do nothing;
|
|---|
| 98 |
|
|---|
| 99 | insert into genres (id, name)
|
|---|
| 100 | values (0, 'Unknown')
|
|---|
| 101 | on conflict (id) do nothing;
|
|---|
| 102 |
|
|---|
| 103 | insert into games (id, title, release_date, created_at)
|
|---|
| 104 | values (0, 'Unknown Game', current_date, current_timestamp)
|
|---|
| 105 | on conflict (id) do nothing;
|
|---|
| 106 |
|
|---|
| 107 | insert into game_modes (id, game_id, mode_name)
|
|---|
| 108 | values (0, 0, 'Unknown')
|
|---|
| 109 | on conflict (id) do nothing;
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 | insert into developers(id, name, country)
|
|---|
| 113 | select *
|
|---|
| 114 | from (
|
|---|
| 115 | values
|
|---|
| 116 | (1, 'Valve', 'United States'),
|
|---|
| 117 | (2, 'Riot Games', 'United States'),
|
|---|
| 118 | (3, 'Blizzard Entertainment', 'United States'),
|
|---|
| 119 | (4, 'Ubisoft', 'France'),
|
|---|
| 120 | (5, 'Epic Games', 'United States'),
|
|---|
| 121 | (6, 'Respawn Entertainment', 'United States'),
|
|---|
| 122 | (7, 'Mojang Studios', 'Sweden'),
|
|---|
| 123 | (8, 'CD Projekt Red', 'Poland'),
|
|---|
| 124 | (9, 'FromSoftware', 'Japan'),
|
|---|
| 125 | (10, 'Supercell', 'Finland'),
|
|---|
| 126 | (11, 'ArenaNet Studios', 'North Macedonia'),
|
|---|
| 127 | (12, 'Digital Storm Games', 'Serbia'),
|
|---|
| 128 | (13, 'Blue Forge Interactive', 'Germany'),
|
|---|
| 129 | (14, 'NovaByte Games', 'Croatia'),
|
|---|
| 130 | (15, 'IronFox Studio', 'Bulgaria')
|
|---|
| 131 | ) as d(id, name, country)
|
|---|
| 132 | on conflict (id) do nothing;
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 | insert into genres(id, name)
|
|---|
| 136 | select *
|
|---|
| 137 | from (
|
|---|
| 138 | values
|
|---|
| 139 | (1, 'FPS'),
|
|---|
| 140 | (2, 'MOBA'),
|
|---|
| 141 | (3, 'Battle Royale'),
|
|---|
| 142 | (4, 'Strategy'),
|
|---|
| 143 | (5, 'RPG'),
|
|---|
| 144 | (6, 'MMORPG'),
|
|---|
| 145 | (7, 'Sports'),
|
|---|
| 146 | (8, 'Racing'),
|
|---|
| 147 | (9, 'Fighting'),
|
|---|
| 148 | (10, 'Survival'),
|
|---|
| 149 | (11, 'Tactical Shooter'),
|
|---|
| 150 | (12, 'Card Game'),
|
|---|
| 151 | (13, 'Simulation'),
|
|---|
| 152 | (14, 'Action'),
|
|---|
| 153 | (15, 'Adventure')
|
|---|
| 154 | ) as g(id, name)
|
|---|
| 155 | on conflict (id) do nothing;
|
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 | insert into games(id, title, release_date, created_at)
|
|---|
| 159 | select *
|
|---|
| 160 | from (
|
|---|
| 161 | values
|
|---|
| 162 | (1, 'Counter-Strike 2', date '2023-09-27', current_timestamp),
|
|---|
| 163 | (2, 'Dota 2', date '2013-07-09', current_timestamp),
|
|---|
| 164 | (3, 'Valorant', date '2020-06-02', current_timestamp),
|
|---|
| 165 | (4, 'League of Legends', date '2009-10-27', current_timestamp),
|
|---|
| 166 | (5, 'Overwatch 2', date '2022-10-04', current_timestamp),
|
|---|
| 167 | (6, 'Rainbow Six Siege', date '2015-12-01', current_timestamp),
|
|---|
| 168 | (7, 'Fortnite', date '2017-07-21', current_timestamp),
|
|---|
| 169 | (8, 'Apex Legends', date '2019-02-04', current_timestamp),
|
|---|
| 170 | (9, 'Minecraft', date '2011-11-18', current_timestamp),
|
|---|
| 171 | (10, 'The Witcher 3', date '2015-05-19', current_timestamp),
|
|---|
| 172 | (11, 'Elden Ring', date '2022-02-25', current_timestamp),
|
|---|
| 173 | (12, 'Clash Royale', date '2016-03-02', current_timestamp),
|
|---|
| 174 | (13, 'FIFA 23', date '2022-09-30', current_timestamp),
|
|---|
| 175 | (14, 'Rocket League', date '2015-07-07', current_timestamp),
|
|---|
| 176 | (15, 'Guild Wars 2', date '2012-08-28', current_timestamp)
|
|---|
| 177 | ) as g(id, title, release_date, created_at)
|
|---|
| 178 | on conflict (id) do nothing;
|
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 | insert into game_genres(game_id, genre_id)
|
|---|
| 182 | select g.id, ((g.id - 1) % 15) + 1
|
|---|
| 183 | from games g
|
|---|
| 184 | where g.id between 1 and 15
|
|---|
| 185 | on conflict do nothing;
|
|---|
| 186 |
|
|---|
| 187 | insert into game_genres(game_id, genre_id)
|
|---|
| 188 | select g.id, ((g.id + 5) % 15) + 1
|
|---|
| 189 | from games g
|
|---|
| 190 | where g.id between 1 and 15
|
|---|
| 191 | on conflict do nothing;
|
|---|
| 192 |
|
|---|
| 193 |
|
|---|
| 194 | insert into game_developers(game_id, developer_id)
|
|---|
| 195 | select g.id, ((g.id - 1) % 15) + 1
|
|---|
| 196 | from games g
|
|---|
| 197 | where g.id between 1 and 15
|
|---|
| 198 | on conflict do nothing;
|
|---|
| 199 |
|
|---|
| 200 |
|
|---|
| 201 | insert into game_modes(id, game_id, mode_name)
|
|---|
| 202 | select
|
|---|
| 203 | ((g.id - 1) * 5) + m.mode_id as id,
|
|---|
| 204 | g.id as game_id,
|
|---|
| 205 | m.mode_name
|
|---|
| 206 | from games g
|
|---|
| 207 | cross join (
|
|---|
| 208 | values
|
|---|
| 209 | (1, '1v1'),
|
|---|
| 210 | (2, '2v2'),
|
|---|
| 211 | (3, '3v3'),
|
|---|
| 212 | (4, '5v5'),
|
|---|
| 213 | (5, 'Practice')
|
|---|
| 214 | ) as m(mode_id, mode_name)
|
|---|
| 215 | where g.id between 1 and 15
|
|---|
| 216 | on conflict (id) do nothing;
|
|---|
| 217 |
|
|---|
| 218 | insert into game_modes(id, game_id, mode_name)
|
|---|
| 219 | values (0, 0, 'Unknown')
|
|---|
| 220 | on conflict (id) do nothing;
|
|---|
| 221 |
|
|---|
| 222 |
|
|---|
| 223 | insert into servers(id, game_id, location_id, server_name, is_active)
|
|---|
| 224 | select
|
|---|
| 225 | ((g.id - 1) * 5) + s.server_no as id,
|
|---|
| 226 | g.id as game_id,
|
|---|
| 227 | l.id as location_id,
|
|---|
| 228 | g.title || ' Server ' || s.server_no as server_name,
|
|---|
| 229 | true as is_active
|
|---|
| 230 | from games g
|
|---|
| 231 | cross join generate_series(1, 5) s(server_no)
|
|---|
| 232 | join lateral (
|
|---|
| 233 | select id
|
|---|
| 234 | from locations
|
|---|
| 235 | where id <> 0
|
|---|
| 236 | order by random()
|
|---|
| 237 | limit 1
|
|---|
| 238 | ) l on true
|
|---|
| 239 | where g.id between 1 and 15
|
|---|
| 240 | on conflict (id) do nothing;
|
|---|
| 241 |
|
|---|
| 242 | insert into servers(id, game_id, location_id, server_name, is_active)
|
|---|
| 243 | values (0, 0, 0, 'Unknown Server', false)
|
|---|
| 244 | on conflict (id) do nothing;
|
|---|
| 245 |
|
|---|
| 246 |
|
|---|
| 247 | insert into linked_accounts(id, user_id, provider_id, external_user_id, nickname, avatar_url, linked_at)
|
|---|
| 248 | select
|
|---|
| 249 | gs as id,
|
|---|
| 250 | gs as user_id,
|
|---|
| 251 | 1 as provider_id,
|
|---|
| 252 | 'external_' || gs as external_user_id,
|
|---|
| 253 | 'player_' || gs as nickname,
|
|---|
| 254 | 'https://cdn.arenanet.local/avatar/' || gs || '.png' as avatar_url,
|
|---|
| 255 | now() - (random() * interval '3 years') as linked_at
|
|---|
| 256 | from generate_series(1, 300000) gs
|
|---|
| 257 | where exists (select 1 from users u where u.id = gs)
|
|---|
| 258 | on conflict (id) do nothing;
|
|---|
| 259 |
|
|---|
| 260 |
|
|---|
| 261 | insert into friendships(id, user_id_low, user_id_high, requested_by_user_id, status_id, created_at, updated_at)
|
|---|
| 262 | select
|
|---|
| 263 | gs as id,
|
|---|
| 264 | gs as user_id_low,
|
|---|
| 265 | gs + 1 as user_id_high,
|
|---|
| 266 | gs as requested_by_user_id,
|
|---|
| 267 | 2 as status_id,
|
|---|
| 268 | t.created_at,
|
|---|
| 269 | t.created_at + (random() * interval '2 years') as updated_at
|
|---|
| 270 | from generate_series(1, 500000) gs
|
|---|
| 271 | cross join lateral (
|
|---|
| 272 | select now() - (random() * interval '4 years') as created_at
|
|---|
| 273 | ) t
|
|---|
| 274 | where exists (select 1 from users u where u.id = gs)
|
|---|
| 275 | and exists (select 1 from users u where u.id = gs + 1)
|
|---|
| 276 | on conflict (id) do nothing;
|
|---|
| 277 |
|
|---|
| 278 |
|
|---|
| 279 | insert into direct_messages(id, sender_id, receiver_id, content, sent_at, read_at)
|
|---|
| 280 | select
|
|---|
| 281 | gs as id,
|
|---|
| 282 | gs as sender_id,
|
|---|
| 283 | gs + 1 as receiver_id,
|
|---|
| 284 | case
|
|---|
| 285 | when gs % 5 = 0 then 'Want to queue ranked later?'
|
|---|
| 286 | when gs % 5 = 1 then 'Good game, well played.'
|
|---|
| 287 | when gs % 5 = 2 then 'Join our team for the tournament.'
|
|---|
| 288 | when gs % 5 = 3 then 'Can you review the match stats?'
|
|---|
| 289 | else 'Let us practice tonight.'
|
|---|
| 290 | end as content,
|
|---|
| 291 | msg.sent_at,
|
|---|
| 292 | case
|
|---|
| 293 | when gs % 4 = 0 then null
|
|---|
| 294 | else msg.sent_at + (random() * interval '30 days')
|
|---|
| 295 | end as read_at
|
|---|
| 296 | from generate_series(1, 700000) gs
|
|---|
| 297 | cross join lateral (
|
|---|
| 298 | select now() - (random() * interval '2 years') as sent_at
|
|---|
| 299 | ) msg
|
|---|
| 300 | where exists (select 1 from users u where u.id = gs)
|
|---|
| 301 | and exists (select 1 from users u where u.id = gs + 1)
|
|---|
| 302 | on conflict (id) do nothing;
|
|---|
| 303 |
|
|---|
| 304 |
|
|---|
| 305 | insert into subscriptions(id, user_id, plan_id, start_at, end_at, is_active)
|
|---|
| 306 | select
|
|---|
| 307 | gs as id,
|
|---|
| 308 | gs as user_id,
|
|---|
| 309 | ((gs - 1) % 4) + 1 as plan_id,
|
|---|
| 310 | now() - (random() * interval '2 years') as start_at,
|
|---|
| 311 | null as end_at,
|
|---|
| 312 | true as is_active
|
|---|
| 313 | from generate_series(1, 500000) gs
|
|---|
| 314 | where exists (select 1 from users u where u.id = gs)
|
|---|
| 315 | on conflict (id) do nothing;
|
|---|
| 316 |
|
|---|
| 317 |
|
|---|
| 318 | insert into payments(id, user_id, subscription_id, amount, currency_code, paid_at, provider_reference)
|
|---|
| 319 | select
|
|---|
| 320 | s.id as id,
|
|---|
| 321 | s.user_id,
|
|---|
| 322 | s.id as subscription_id,
|
|---|
| 323 | case
|
|---|
| 324 | when s.id % 3 = 0 then 4.99
|
|---|
| 325 | when s.id % 3 = 1 then 9.99
|
|---|
| 326 | else 14.99
|
|---|
| 327 | end as amount,
|
|---|
| 328 | 'EUR' as currency_code,
|
|---|
| 329 | s.start_at + interval '5 minutes' as paid_at,
|
|---|
| 330 | 'PAY-' || s.id as provider_reference
|
|---|
| 331 | from subscriptions s
|
|---|
| 332 | where s.id between 1 and 500000
|
|---|
| 333 | on conflict (id) do nothing;
|
|---|
| 334 |
|
|---|
| 335 |
|
|---|
| 336 | insert into preferences(user_id, game_id, is_favorite, created_at)
|
|---|
| 337 | select
|
|---|
| 338 | ((gs - 1) / 5) + 1 as user_id,
|
|---|
| 339 | ((gs - 1) % 5) + 1 as game_id,
|
|---|
| 340 | true as is_favorite,
|
|---|
| 341 | now() - (random() * interval '3 years') as created_at
|
|---|
| 342 | from generate_series(1, 500000) gs
|
|---|
| 343 | where exists (select 1 from users u where u.id = ((gs - 1) / 5) + 1)
|
|---|
| 344 | and exists (select 1 from games g where g.id = ((gs - 1) % 5) + 1)
|
|---|
| 345 | on conflict do nothing;
|
|---|
| 346 |
|
|---|
| 347 |
|
|---|
| 348 | insert into notifications
|
|---|
| 349 | (
|
|---|
| 350 | id,
|
|---|
| 351 | user_id,
|
|---|
| 352 | type_id,
|
|---|
| 353 | title,
|
|---|
| 354 | message,
|
|---|
| 355 | is_read,
|
|---|
| 356 | created_at,
|
|---|
| 357 | preference_user_id,
|
|---|
| 358 | preference_game_id
|
|---|
| 359 | )
|
|---|
| 360 | select
|
|---|
| 361 | gs as id,
|
|---|
| 362 | ((gs - 1) / 5) + 1 as user_id,
|
|---|
| 363 | 1 as type_id,
|
|---|
| 364 | case
|
|---|
| 365 | when gs % 3 = 0 then 'Tournament reminder'
|
|---|
| 366 | when gs % 3 = 1 then 'New match available'
|
|---|
| 367 | else 'Game recommendation'
|
|---|
| 368 | end as title,
|
|---|
| 369 | case
|
|---|
| 370 | when gs % 3 = 0 then 'A tournament for one of your favorite games starts soon.'
|
|---|
| 371 | when gs % 3 = 1 then 'A new match has been scheduled.'
|
|---|
| 372 | else 'You may like this game based on your preferences.'
|
|---|
| 373 | end as message,
|
|---|
| 374 | gs % 4 = 0 as is_read,
|
|---|
| 375 | now() - (random() * interval '1 year') as created_at,
|
|---|
| 376 | ((gs - 1) / 5) + 1 as preference_user_id,
|
|---|
| 377 | ((gs - 1) % 5) + 1 as preference_game_id
|
|---|
| 378 | from generate_series(1, 100000) gs
|
|---|
| 379 | where exists (
|
|---|
| 380 | select 1
|
|---|
| 381 | from preferences p
|
|---|
| 382 | where p.user_id = ((gs - 1) / 5) + 1
|
|---|
| 383 | and p.game_id = ((gs - 1) % 5) + 1
|
|---|
| 384 | )
|
|---|
| 385 | on conflict (id) do nothing;
|
|---|
| 386 |
|
|---|
| 387 |
|
|---|
| 388 | insert into reviews(id, user_id, game_id, rating, comment, created_at)
|
|---|
| 389 | select
|
|---|
| 390 | gs as id,
|
|---|
| 391 | ((gs - 1) / 15) + 1 as user_id,
|
|---|
| 392 | ((gs - 1) % 15) + 1 as game_id,
|
|---|
| 393 | 1 + floor(random() * 10)::int as rating,
|
|---|
| 394 | case
|
|---|
| 395 | when gs % 4 = 0 then 'Very competitive and fun.'
|
|---|
| 396 | when gs % 4 = 1 then 'Good matchmaking and active community.'
|
|---|
| 397 | when gs % 4 = 2 then 'Needs better servers, but gameplay is solid.'
|
|---|
| 398 | else 'Great for tournaments and team play.'
|
|---|
| 399 | end as comment,
|
|---|
| 400 | now() - (random() * interval '3 years') as created_at
|
|---|
| 401 | from generate_series(1, 20000) gs
|
|---|
| 402 | where exists (select 1 from users u where u.id = ((gs - 1) / 15) + 1)
|
|---|
| 403 | on conflict (id) do nothing;
|
|---|
| 404 |
|
|---|
| 405 |
|
|---|
| 406 | insert into achievements(id, game_id, title, description)
|
|---|
| 407 | select
|
|---|
| 408 | ((g.id - 1) * 5) + a.achievement_no as id,
|
|---|
| 409 | g.id as game_id,
|
|---|
| 410 | case a.achievement_no
|
|---|
| 411 | when 1 then 'First Victory'
|
|---|
| 412 | when 2 then 'Sharp Shooter'
|
|---|
| 413 | when 3 then 'Team Player'
|
|---|
| 414 | when 4 then 'Tournament Debut'
|
|---|
| 415 | else 'Elite Competitor'
|
|---|
| 416 | end as title,
|
|---|
| 417 | case a.achievement_no
|
|---|
| 418 | when 1 then 'Win your first match.'
|
|---|
| 419 | when 2 then 'Achieve a high accuracy score.'
|
|---|
| 420 | when 3 then 'Play multiple matches with a team.'
|
|---|
| 421 | when 4 then 'Join your first tournament.'
|
|---|
| 422 | else 'Reach a high competitive ranking.'
|
|---|
| 423 | end as description
|
|---|
| 424 | from games g
|
|---|
| 425 | cross join generate_series(1, 5) a(achievement_no)
|
|---|
| 426 | where g.id between 1 and 15
|
|---|
| 427 | on conflict (id) do nothing;
|
|---|
| 428 |
|
|---|
| 429 | insert into achievements(id, game_id, title, description)
|
|---|
| 430 | values (0, 0, 'Unknown Achievement', 'Default achievement.')
|
|---|
| 431 | on conflict (id) do nothing;
|
|---|
| 432 |
|
|---|
| 433 |
|
|---|
| 434 | insert into user_achievements(id, user_id, achievement_id, unlocked_at)
|
|---|
| 435 | select
|
|---|
| 436 | gs as id,
|
|---|
| 437 | gs as user_id,
|
|---|
| 438 | ((gs - 1) % 24) + 1 as achievement_id,
|
|---|
| 439 | now() - (random() * interval '3 years') as unlocked_at
|
|---|
| 440 | from generate_series(1, 500000) gs
|
|---|
| 441 | where exists (select 1 from users u where u.id = gs)
|
|---|
| 442 | on conflict (id) do nothing;
|
|---|
| 443 |
|
|---|
| 444 |
|
|---|
| 445 | insert into teams(id, name, created_at)
|
|---|
| 446 | select
|
|---|
| 447 | gs as id,
|
|---|
| 448 | 'Team_' || gs as name,
|
|---|
| 449 | now() - (random() * interval '4 years') as created_at
|
|---|
| 450 | from generate_series(1, 100000) gs
|
|---|
| 451 | on conflict (id) do nothing;
|
|---|
| 452 |
|
|---|
| 453 |
|
|---|
| 454 | insert into team_memberships(team_id, user_id, role_id, joined_at, is_active)
|
|---|
| 455 | select
|
|---|
| 456 | ((gs - 1) / 5) + 1 as team_id,
|
|---|
| 457 | gs as user_id,
|
|---|
| 458 | case
|
|---|
| 459 | when gs % 5 = 1 then 4
|
|---|
| 460 | else 1
|
|---|
| 461 | end as role_id,
|
|---|
| 462 | now() - (random() * interval '3 years') as joined_at,
|
|---|
| 463 | true as is_active
|
|---|
| 464 | from generate_series(1, 500000) gs
|
|---|
| 465 | where exists (select 1 from users u where u.id = gs)
|
|---|
| 466 | on conflict do nothing;
|
|---|
| 467 |
|
|---|
| 468 |
|
|---|
| 469 | delete from participant_stats;
|
|---|
| 470 | delete from stat_types;
|
|---|
| 471 | delete from match_participants;
|
|---|
| 472 | delete from match_teams;
|
|---|
| 473 | delete from matches;
|
|---|
| 474 | delete from tournament_teams;
|
|---|
| 475 | delete from tournaments;
|
|---|
| 476 |
|
|---|
| 477 |
|
|---|
| 478 | insert into teams(id, name, created_at)
|
|---|
| 479 | values (0, 'Unknown Team', now())
|
|---|
| 480 | on conflict (id) do nothing;
|
|---|
| 481 |
|
|---|
| 482 |
|
|---|
| 483 | insert into tournaments
|
|---|
| 484 | (
|
|---|
| 485 | id,
|
|---|
| 486 | game_id,
|
|---|
| 487 | name,
|
|---|
| 488 | organizer_team_id,
|
|---|
| 489 | prize_pool,
|
|---|
| 490 | starts_at,
|
|---|
| 491 | ends_at,
|
|---|
| 492 | created_at
|
|---|
| 493 | )
|
|---|
| 494 | select
|
|---|
| 495 | gs as id,
|
|---|
| 496 | g.id as game_id,
|
|---|
| 497 | 'Tournament_' || gs as name,
|
|---|
| 498 | ((gs - 1) % 100000) + 1 as organizer_team_id,
|
|---|
| 499 | case
|
|---|
| 500 | when gs % 5 = 0 then 10000
|
|---|
| 501 | when gs % 5 = 1 then 5000
|
|---|
| 502 | when gs % 5 = 2 then 2500
|
|---|
| 503 | when gs % 5 = 3 then 1000
|
|---|
| 504 | else 500
|
|---|
| 505 | end as prize_pool,
|
|---|
| 506 | now() - interval '1 year' + (gs * interval '3 hours') as starts_at,
|
|---|
| 507 | now() - interval '1 year' + (gs * interval '3 hours') + interval '6 hours' as ends_at,
|
|---|
| 508 | now() - interval '1 year' + (gs * interval '2 hours') as created_at
|
|---|
| 509 | from generate_series(1, 2000) gs
|
|---|
| 510 | join lateral (
|
|---|
| 511 | select id
|
|---|
| 512 | from games
|
|---|
| 513 | where id <> 0
|
|---|
| 514 | order by id
|
|---|
| 515 | offset ((gs - 1) % (select count(*) from games where id <> 0))
|
|---|
| 516 | limit 1
|
|---|
| 517 | ) g on true
|
|---|
| 518 | on conflict (id) do nothing;
|
|---|
| 519 |
|
|---|
| 520 |
|
|---|
| 521 | insert into tournament_teams(tournament_id, team_id, joined_at)
|
|---|
| 522 | select
|
|---|
| 523 | t.id as tournament_id,
|
|---|
| 524 | ((t.id - 1) * 8) + slot.slot_no as team_id,
|
|---|
| 525 | t.created_at + interval '1 hour' as joined_at
|
|---|
| 526 | from tournaments t
|
|---|
| 527 | cross join generate_series(1, 8) slot(slot_no)
|
|---|
| 528 | where t.id between 1 and 2000
|
|---|
| 529 | on conflict do nothing;
|
|---|
| 530 |
|
|---|
| 531 |
|
|---|
| 532 | insert into matches
|
|---|
| 533 | (
|
|---|
| 534 | id,
|
|---|
| 535 | game_id,
|
|---|
| 536 | game_mode_id,
|
|---|
| 537 | tournament_id,
|
|---|
| 538 | server_id,
|
|---|
| 539 | status_id,
|
|---|
| 540 | started_at,
|
|---|
| 541 | ended_at,
|
|---|
| 542 | created_at
|
|---|
| 543 | )
|
|---|
| 544 | select
|
|---|
| 545 | gs as id,
|
|---|
| 546 | t.game_id,
|
|---|
| 547 | gm.id as game_mode_id,
|
|---|
| 548 | t.id as tournament_id,
|
|---|
| 549 | coalesce(
|
|---|
| 550 | (
|
|---|
| 551 | select s.id
|
|---|
| 552 | from servers s
|
|---|
| 553 | where s.game_id = t.game_id
|
|---|
| 554 | order by s.id
|
|---|
| 555 | limit 1
|
|---|
| 556 | ),
|
|---|
| 557 | 0
|
|---|
| 558 | ) as server_id,
|
|---|
| 559 | 3 as status_id,
|
|---|
| 560 | t.starts_at + ((gs % 20) * interval '30 minutes') as started_at,
|
|---|
| 561 | t.starts_at + ((gs % 20) * interval '30 minutes') + interval '45 minutes' as ended_at,
|
|---|
| 562 | t.created_at as created_at
|
|---|
| 563 | from generate_series(1, 1000000) gs
|
|---|
| 564 | join tournaments t
|
|---|
| 565 | on t.id = ((gs - 1) % 2000) + 1
|
|---|
| 566 | join game_modes gm
|
|---|
| 567 | on gm.game_id = t.game_id
|
|---|
| 568 | and lower(gm.mode_name) =
|
|---|
| 569 | case
|
|---|
| 570 | when gs <= 300000 then '5v5'
|
|---|
| 571 | when gs <= 600000 then '3v3'
|
|---|
| 572 | when gs <= 800000 then '2v2'
|
|---|
| 573 | else '1v1'
|
|---|
| 574 | end
|
|---|
| 575 | on conflict (id) do nothing;
|
|---|
| 576 |
|
|---|
| 577 |
|
|---|
| 578 | insert into match_teams(match_id, team_id, side_label)
|
|---|
| 579 | select
|
|---|
| 580 | m.id as match_id,
|
|---|
| 581 | ((m.tournament_id - 1) * 8) + 1 as team_id,
|
|---|
| 582 | 'A' as side_label
|
|---|
| 583 | from matches m
|
|---|
| 584 | where m.id between 1 and 1000000
|
|---|
| 585 | on conflict do nothing;
|
|---|
| 586 |
|
|---|
| 587 | insert into match_teams(match_id, team_id, side_label)
|
|---|
| 588 | select
|
|---|
| 589 | m.id as match_id,
|
|---|
| 590 | ((m.tournament_id - 1) * 8) + 2 as team_id,
|
|---|
| 591 | 'B' as side_label
|
|---|
| 592 | from matches m
|
|---|
| 593 | where m.id between 1 and 1000000
|
|---|
| 594 | on conflict do nothing;
|
|---|
| 595 |
|
|---|
| 596 |
|
|---|
| 597 | insert into match_participants
|
|---|
| 598 | (
|
|---|
| 599 | id,
|
|---|
| 600 | match_id,
|
|---|
| 601 | user_id,
|
|---|
| 602 | team_id,
|
|---|
| 603 | result_id,
|
|---|
| 604 | score,
|
|---|
| 605 | elo_change,
|
|---|
| 606 | joined_at
|
|---|
| 607 | )
|
|---|
| 608 | select
|
|---|
| 609 | row_number() over (order by m.id, mt.side_label, member.slot_no) as id,
|
|---|
| 610 | m.id as match_id,
|
|---|
| 611 | member.user_id,
|
|---|
| 612 | mt.team_id,
|
|---|
| 613 | case
|
|---|
| 614 | when mt.side_label = 'A' then 1
|
|---|
| 615 | else 2
|
|---|
| 616 | end as result_id,
|
|---|
| 617 | case
|
|---|
| 618 | when mt.side_label = 'A' then 16 + floor(random() * 10)::int
|
|---|
| 619 | else 5 + floor(random() * 11)::int
|
|---|
| 620 | end as score,
|
|---|
| 621 | case
|
|---|
| 622 | when mt.side_label = 'A' then 10 + floor(random() * 20)::int
|
|---|
| 623 | else -20 + floor(random() * 10)::int
|
|---|
| 624 | end as elo_change,
|
|---|
| 625 | m.started_at - interval '5 minutes' as joined_at
|
|---|
| 626 | from matches m
|
|---|
| 627 | join game_modes gm on gm.id = m.game_mode_id
|
|---|
| 628 | join match_teams mt on mt.match_id = m.id
|
|---|
| 629 | join lateral (
|
|---|
| 630 | select
|
|---|
| 631 | tm.user_id,
|
|---|
| 632 | row_number() over (order by tm.user_id) as slot_no
|
|---|
| 633 | from team_memberships tm
|
|---|
| 634 | where tm.team_id = mt.team_id
|
|---|
| 635 | and tm.is_active = true
|
|---|
| 636 | order by tm.user_id
|
|---|
| 637 | limit
|
|---|
| 638 | case lower(gm.mode_name)
|
|---|
| 639 | when '5v5' then 5
|
|---|
| 640 | when '3v3' then 3
|
|---|
| 641 | when '2v2' then 2
|
|---|
| 642 | when '1v1' then 1
|
|---|
| 643 | else 0
|
|---|
| 644 | end
|
|---|
| 645 | ) member on true
|
|---|
| 646 | where m.id between 1 and 1000000
|
|---|
| 647 | on conflict (id) do nothing;
|
|---|
| 648 |
|
|---|
| 649 |
|
|---|
| 650 | insert into stat_types(id, game_id, name, unit)
|
|---|
| 651 | select
|
|---|
| 652 | ((g.id - 1) * 5) + s.stat_no as id,
|
|---|
| 653 | g.id as game_id,
|
|---|
| 654 | case s.stat_no
|
|---|
| 655 | when 1 then 'kills'
|
|---|
| 656 | when 2 then 'deaths'
|
|---|
| 657 | when 3 then 'assists'
|
|---|
| 658 | when 4 then 'damage'
|
|---|
| 659 | else 'accuracy'
|
|---|
| 660 | end as name,
|
|---|
| 661 | case s.stat_no
|
|---|
| 662 | when 4 then 'points'
|
|---|
| 663 | when 5 then '%'
|
|---|
| 664 | else 'count'
|
|---|
| 665 | end as unit
|
|---|
| 666 | from games g
|
|---|
| 667 | cross join generate_series(1, 5) s(stat_no)
|
|---|
| 668 | where g.id <> 0
|
|---|
| 669 | on conflict (id) do nothing;
|
|---|
| 670 |
|
|---|
| 671 | insert into stat_types(id, game_id, name, unit)
|
|---|
| 672 | values (0, 0, 'unknown', null)
|
|---|
| 673 | on conflict (id) do nothing;
|
|---|
| 674 |
|
|---|
| 675 |
|
|---|
| 676 | insert into participant_stats(match_participant_id, stat_type_id, value)
|
|---|
| 677 | select
|
|---|
| 678 | mp.id as match_participant_id,
|
|---|
| 679 | ((m.game_id - 1) * 5) + st.stat_no as stat_type_id,
|
|---|
| 680 | case st.stat_no
|
|---|
| 681 | when 1 then floor(random() * 35)
|
|---|
| 682 | when 2 then floor(random() * 25)
|
|---|
| 683 | when 3 then floor(random() * 20)
|
|---|
| 684 | when 4 then floor(random() * 4000)
|
|---|
| 685 | else round((40 + random() * 60)::numeric, 2)
|
|---|
| 686 | end as value
|
|---|
| 687 | from match_participants mp
|
|---|
| 688 | join matches m on m.id = mp.match_id
|
|---|
| 689 | cross join generate_series(1, 5) st(stat_no)
|
|---|
| 690 | where mp.id between 1 and 6000000
|
|---|
| 691 | on conflict do nothing;
|
|---|
| 692 |
|
|---|
| 693 |
|
|---|
| 694 | select 'tournaments' as table_name, count(*) from tournaments
|
|---|
| 695 | union all select 'tournament_teams', count(*) from tournament_teams
|
|---|
| 696 | union all select 'matches', count(*) from matches
|
|---|
| 697 | union all select 'match_teams', count(*) from match_teams
|
|---|
| 698 | union all select 'match_participants', count(*) from match_participants
|
|---|
| 699 | union all select 'stat_types', count(*) from stat_types
|
|---|
| 700 | union all select 'participant_stats', count(*) from participant_stats;
|
|---|
| 701 |
|
|---|
| 702 |
|
|---|
| 703 | select
|
|---|
| 704 | gm.mode_name,
|
|---|
| 705 | count(*) as matches
|
|---|
| 706 | from matches m
|
|---|
| 707 | join game_modes gm on gm.id = m.game_mode_id
|
|---|
| 708 | group by gm.mode_name
|
|---|
| 709 | order by gm.mode_name;
|
|---|
| 710 |
|
|---|
| 711 |
|
|---|
| 712 | select 'developers' as table_name, count(*) from developers
|
|---|
| 713 | union all select 'genres', count(*) from genres
|
|---|
| 714 | union all select 'games', count(*) from games
|
|---|
| 715 | union all select 'game_modes', count(*) from game_modes
|
|---|
| 716 | union all select 'servers', count(*) from servers
|
|---|
| 717 | union all select 'linked_accounts', count(*) from linked_accounts
|
|---|
| 718 | union all select 'friendships', count(*) from friendships
|
|---|
| 719 | union all select 'direct_messages', count(*) from direct_messages
|
|---|
| 720 | union all select 'subscriptions', count(*) from subscriptions
|
|---|
| 721 | union all select 'payments', count(*) from payments
|
|---|
| 722 | union all select 'preferences', count(*) from preferences
|
|---|
| 723 | union all select 'notifications', count(*) from notifications
|
|---|
| 724 | union all select 'reviews', count(*) from reviews
|
|---|
| 725 | union all select 'achievements', count(*) from achievements
|
|---|
| 726 | union all select 'user_achievements', count(*) from user_achievements
|
|---|
| 727 | union all select 'teams', count(*) from teams
|
|---|
| 728 | union all select 'team_memberships', count(*) from team_memberships
|
|---|
| 729 | union all select 'tournaments', count(*) from tournaments
|
|---|
| 730 | union all select 'tournament_teams', count(*) from tournament_teams
|
|---|
| 731 | union all select 'matches', count(*) from matches
|
|---|
| 732 | union all select 'match_teams', count(*) from match_teams
|
|---|
| 733 | union all select 'match_participants', count(*) from match_participants
|
|---|
| 734 | union all select 'stat_types', count(*) from stat_types
|
|---|
| 735 | union all select 'participant_stats', count(*) from participant_stats; |
|---|