@@ -110,7 +110,12 @@ def upgrade() -> None:
110110 op .create_table (
111111 "comments" ,
112112 sa .Column ("id" , sa .Integer (), autoincrement = True , nullable = False ),
113- sa .Column ("target_id" , sa .Integer (), nullable = False ),
113+ sa .Column (
114+ "target_id" ,
115+ sa .Integer (),
116+ nullable = False ,
117+ comment = "replay, map, or set id" ,
118+ ),
114119 sa .Column ("target_type" , mysql .ENUM ("replay" , "map" , "song" ), nullable = False ),
115120 sa .Column ("userid" , sa .Integer (), nullable = False ),
116121 sa .Column ("time" , sa .Integer (), nullable = False ),
@@ -119,7 +124,7 @@ def upgrade() -> None:
119124 mysql .VARCHAR (charset = "utf8mb3" , collation = "utf8mb3_general_ci" , length = 80 ),
120125 nullable = False ,
121126 ),
122- sa .Column ("colour" , sa .CHAR (length = 6 ), nullable = True ),
127+ sa .Column ("colour" , sa .CHAR (length = 6 ), nullable = True , comment = "rgb hex string" ),
123128 sa .PrimaryKeyConstraint ("id" ),
124129 )
125130 op .create_table (
@@ -133,7 +138,12 @@ def upgrade() -> None:
133138 "ingame_logins" ,
134139 sa .Column ("id" , sa .Integer (), autoincrement = True , nullable = False ),
135140 sa .Column ("userid" , sa .Integer (), nullable = False ),
136- sa .Column ("ip" , sa .String (length = 45 ), nullable = False ),
141+ sa .Column (
142+ "ip" ,
143+ sa .String (length = 45 ),
144+ nullable = False ,
145+ comment = "maxlen for ipv6" ,
146+ ),
137147 sa .Column ("osu_ver" , sa .Date (), nullable = False ),
138148 sa .Column ("osu_stream" , sa .String (length = 11 ), nullable = False ),
139149 sa .Column ("datetime" , sa .DateTime (), nullable = False ),
@@ -142,7 +152,12 @@ def upgrade() -> None:
142152 op .create_table (
143153 "logs" ,
144154 sa .Column ("id" , sa .Integer (), autoincrement = True , nullable = False ),
145- sa .Column ("from" , sa .Integer (), nullable = False ),
155+ sa .Column (
156+ "from" ,
157+ sa .Integer (),
158+ nullable = False ,
159+ comment = "both from and to are playerids" ,
160+ ),
146161 sa .Column ("to" , sa .Integer (), nullable = False ),
147162 sa .Column ("action" , sa .String (length = 32 ), nullable = False ),
148163 sa .Column (
@@ -193,7 +208,7 @@ def upgrade() -> None:
193208 "maps" ,
194209 sa .Column (
195210 "server" ,
196- mysql .ENUM ("replay " , "map" , "song " ),
211+ mysql .ENUM ("osu! " , "private " ),
197212 server_default = "osu!" ,
198213 nullable = False ,
199214 ),
@@ -343,6 +358,12 @@ def upgrade() -> None:
343358 sa .Column ("online_checksum" , mysql .CHAR (length = 32 ), nullable = False ),
344359 sa .PrimaryKeyConstraint ("id" ),
345360 )
361+ op .create_index (
362+ "scores_fetch_leaderboard_generic_index" ,
363+ "scores" ,
364+ ["map_md5" , "status" , "mode" ],
365+ unique = False ,
366+ )
346367 op .create_index ("scores_map_md5_index" , "scores" , ["map_md5" ], unique = False )
347368 op .create_index ("scores_mode_index" , "scores" , ["mode" ], unique = False )
348369 op .create_index ("scores_mods_index" , "scores" , ["mods" ], unique = False )
@@ -357,12 +378,6 @@ def upgrade() -> None:
357378 op .create_index ("scores_score_index" , "scores" , ["score" ], unique = False )
358379 op .create_index ("scores_status_index" , "scores" , ["status" ], unique = False )
359380 op .create_index ("scores_userid_index" , "scores" , ["userid" ], unique = False )
360- op .create_index (
361- "scores_fetch_leaderboard_generic_index" ,
362- "scores" ,
363- ["map_md5" , "status" , "mode" ],
364- unique = False ,
365- )
366381 op .create_table (
367382 "stats" ,
368383 sa .Column ("id" , sa .Integer (), autoincrement = True , nullable = False ),
@@ -406,7 +421,7 @@ def upgrade() -> None:
406421 "tourney_pool_maps" ,
407422 sa .Column ("map_id" , sa .Integer (), nullable = False ),
408423 sa .Column ("pool_id" , sa .Integer (), nullable = False ),
409- sa .Column ("mods" , mysql . BIGINT (), nullable = False ),
424+ sa .Column ("mods" , sa . Integer (), nullable = False ),
410425 sa .Column ("slot" , mysql .TINYINT (), nullable = False ),
411426 sa .PrimaryKeyConstraint ("map_id" , "pool_id" ),
412427 )
@@ -425,7 +440,7 @@ def upgrade() -> None:
425440 op .create_table (
426441 "tourney_pools" ,
427442 sa .Column ("id" , sa .Integer (), autoincrement = True , nullable = False ),
428- sa .Column ("name" , mysql .VARCHAR (length = 64 ), nullable = False ),
443+ sa .Column ("name" , mysql .VARCHAR (length = 16 ), nullable = False ),
429444 sa .Column ("created_at" , sa .DateTime (), nullable = False ),
430445 sa .Column ("created_by" , sa .Integer (), nullable = False ),
431446 sa .PrimaryKeyConstraint ("id" ),
@@ -457,8 +472,8 @@ def upgrade() -> None:
457472 op .create_table (
458473 "users" ,
459474 sa .Column ("id" , sa .Integer (), autoincrement = True , nullable = False ),
460- sa .Column ("name" , mysql .MEDIUMTEXT ( ), nullable = False ),
461- sa .Column ("safe_name" , mysql .MEDIUMTEXT ( ), nullable = False ),
475+ sa .Column ("name" , mysql .VARCHAR ( length = 32 ), nullable = False ),
476+ sa .Column ("safe_name" , mysql .VARCHAR ( length = 32 ), nullable = False ),
462477 sa .Column ("email" , sa .String (length = 254 ), nullable = False ),
463478 sa .Column ("priv" , sa .Integer (), server_default = "1" , nullable = False ),
464479 sa .Column ("pw_bcrypt" , mysql .CHAR (length = 60 ), nullable = False ),
@@ -527,7 +542,6 @@ def downgrade() -> None:
527542 op .drop_index ("stats_pp_index" , table_name = "stats" )
528543 op .drop_index ("stats_mode_index" , table_name = "stats" )
529544 op .drop_table ("stats" )
530- op .drop_index ("scores_fetch_leaderboard_generic_index" , table_name = "scores" )
531545 op .drop_index ("scores_userid_index" , table_name = "scores" )
532546 op .drop_index ("scores_status_index" , table_name = "scores" )
533547 op .drop_index ("scores_score_index" , table_name = "scores" )
@@ -537,6 +551,7 @@ def downgrade() -> None:
537551 op .drop_index ("scores_mods_index" , table_name = "scores" )
538552 op .drop_index ("scores_mode_index" , table_name = "scores" )
539553 op .drop_index ("scores_map_md5_index" , table_name = "scores" )
554+ op .drop_index ("scores_fetch_leaderboard_generic_index" , table_name = "scores" )
540555 op .drop_table ("scores" )
541556 op .drop_table ("ratings" )
542557 op .drop_index ("maps_status_index" , table_name = "maps" )
0 commit comments