]> git.xonotic.org Git - xonotic/xonstatdb.git/blobdiff - scripts/gen_partitions.shl
Add a new table for player skills.
[xonotic/xonstatdb.git] / scripts / gen_partitions.shl
index b687eef6167483ae13500da58678c86482eff495..a189064003c7b571937433273cb600a672dbf76d 100755 (executable)
@@ -30,7 +30,14 @@ do
         printf "CREATE INDEX %s_%s%s_ix001 on %s_%s%s(create_dt);\n" $table $year $qtr $table $year $qtr
 
         # conditional indexes that depend on the table
-        if [[ $table = "player_game_stats" || $table = "player_weapon_stats" ]]
+        if [[ $table = "games" ]]
+        then
+            printf "CREATE INDEX %s_%s%s_ix002 on %s_%s%s using gin(players);\n" $table $year $qtr $table $year $qtr
+            printf "CREATE UNIQUE INDEX %s_%s%s_pk on %s_%s%s(game_id);\n" $table $year $qtr $table $year $qtr
+            printf "ALTER TABLE %s_%s%s ADD PRIMARY KEY USING INDEX %s_%s%s_pk;\n" $table $year $qtr $table $year $qtr
+        fi
+        
+        if [[ $table = "player_game_stats" || $table = "player_weapon_stats" || $table = "player_game_nonparticipants" ]]
         then
             printf "CREATE INDEX %s_%s%s_ix002 on %s_%s%s(game_id);\n" $table $year $qtr $table $year $qtr
             printf "CREATE INDEX %s_%s%s_ix003 on %s_%s%s(player_id);\n" $table $year $qtr $table $year $qtr
@@ -41,11 +48,6 @@ do
             printf "CREATE INDEX %s_%s%s_ix002 on %s_%s%s(game_id);\n" $table $year $qtr $table $year $qtr
         fi
 
-        if [[ $table = "games" ]]
-        then
-            printf "CREATE INDEX %s_%s%s_ix002 on %s_%s%s using gin(players);\n" $table $year $qtr $table $year $qtr
-        fi
-
         printf "\n"
     done
 done