@@ -188,6 +188,115 @@ namespace :leaguepedia do
188188 puts "Done."
189189 end
190190
191+ desc "Create lp_* tables in Supabase (leaguepedia DB) — idempotent"
192+ task setup_supabase : :environment do
193+ conn = LeaguepediaRecord . connection
194+
195+ unless conn . table_exists? ( :lp_matches )
196+ conn . create_table :lp_matches do |t |
197+ t . string :overview_page , null : false
198+ t . string :team1
199+ t . string :team2
200+ t . string :datetime_utc
201+ t . integer :best_of
202+ t . string :winner
203+ t . integer :team1_score
204+ t . integer :team2_score
205+ t . integer :match_day
206+ t . string :phase
207+ t . timestamps
208+ end
209+ conn . add_index :lp_matches , :overview_page
210+ conn . add_index :lp_matches , :datetime_utc
211+ puts " created lp_matches"
212+ else
213+ puts " lp_matches already exists"
214+ end
215+
216+ unless conn . table_exists? ( :lp_games )
217+ conn . create_table :lp_games do |t |
218+ t . string :unique_game , null : false
219+ t . string :tournament
220+ t . string :team1
221+ t . string :team2
222+ t . string :winner
223+ t . string :gamelength
224+ t . string :datetime_utc
225+ t . text :team1_picks
226+ t . text :team2_picks
227+ t . text :team1_bans
228+ t . text :team2_bans
229+ t . integer :team1_kills
230+ t . integer :team2_kills
231+ t . integer :team1_gold
232+ t . integer :team2_gold
233+ t . string :patch
234+ t . integer :team1_towers
235+ t . integer :team2_towers
236+ t . integer :team1_inhibitors
237+ t . integer :team2_inhibitors
238+ t . integer :team1_dragons
239+ t . integer :team2_dragons
240+ t . integer :team1_barons
241+ t . integer :team2_barons
242+ t . integer :team1_rift_heralds
243+ t . integer :team2_rift_heralds
244+ t . integer :team1_void_grubs
245+ t . integer :team2_void_grubs
246+ t . string :win_type
247+ t . timestamps
248+ end
249+ conn . add_index :lp_games , :unique_game , unique : true
250+ conn . add_index :lp_games , :tournament
251+ puts " created lp_games"
252+ else
253+ puts " lp_games already exists"
254+ end
255+
256+ unless conn . table_exists? ( :lp_players )
257+ conn . create_table :lp_players do |t |
258+ t . string :unique_game , null : false
259+ t . string :tournament
260+ t . string :player_link
261+ t . string :champion
262+ t . integer :kills
263+ t . integer :deaths
264+ t . integer :assists
265+ t . integer :cs
266+ t . integer :gold
267+ t . integer :damage_to_champions
268+ t . string :team
269+ t . string :role
270+ t . string :side
271+ t . timestamps
272+ end
273+ conn . add_index :lp_players , [ :unique_game , :player_link ] , unique : true
274+ conn . add_index :lp_players , :tournament
275+ conn . add_index :lp_players , :player_link
276+ puts " created lp_players"
277+ else
278+ puts " lp_players already exists"
279+ end
280+
281+ unless conn . table_exists? ( :lp_champion_stats )
282+ conn . create_table :lp_champion_stats do |t |
283+ t . string :tournament , null : false
284+ t . string :champion , null : false
285+ t . integer :picks , default : 0
286+ t . integer :bans , default : 0
287+ t . integer :wins , default : 0
288+ t . integer :games , default : 0
289+ t . timestamps
290+ end
291+ conn . add_index :lp_champion_stats , [ :tournament , :champion ] , unique : true
292+ puts " created lp_champion_stats"
293+ else
294+ puts " lp_champion_stats already exists"
295+ end
296+
297+ puts "Supabase setup complete."
298+ end
299+
191300 desc "Show current DB counts"
192301 task status : :environment do
193302 puts "DB Status:"
0 commit comments