From a653dfe34965d9f6d331db37c16c337e55f770e2 Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Sat, 19 Dec 2020 11:00:21 -0500 Subject: [PATCH] Add partitions through 2025. --- tables/games.tab | 180 +++++++++++++++++++ tables/player_game_frag_matrix.tab | 121 +++++++++++++ tables/player_game_nonparticipants.tab | 8 +- tables/player_game_stats.tab | 162 +++++++++++++++++ tables/player_weapon_stats.tab | 162 +++++++++++++++++ tables/team_game_stats.tab | 141 +++++++++++++++ triggers/games_ins_trg.sql | 91 +++++----- triggers/player_game_frag_matrix_ins_trg.sql | 60 +++++-- triggers/player_game_stats_ins_trg.sql | 90 +++++----- triggers/player_weapon_stats_ins_trg.sql | 90 +++++----- triggers/team_game_stats_ins_trg.sql | 90 +++++----- 11 files changed, 976 insertions(+), 219 deletions(-) diff --git a/tables/games.tab b/tables/games.tab index cf63852..831208f 100755 --- a/tables/games.tab +++ b/tables/games.tab @@ -141,3 +141,183 @@ CREATE TABLE IF NOT EXISTS xonstat.games_2020q4 ( CHECK ( create_dt >= DATE '2020-10-01' AND create_dt < DATE '2021-01-01' ) ) INHERITS (games); +CREATE TABLE IF NOT EXISTS xonstat.games_2021q1 ( + CHECK ( create_dt >= DATE '2021-01-01' AND create_dt < DATE '2021-04-01' ) +) INHERITS (games); + +CREATE INDEX games_2021q1_ix001 on games_2021q1(create_dt); +CREATE INDEX games_2021q1_ix002 on games_2021q1 using gin(players); +CREATE UNIQUE INDEX games_2021q1_pk on games_2021q1(game_id); +ALTER TABLE games_2021q1 ADD PRIMARY KEY USING INDEX games_2021q1_pk; + +CREATE TABLE IF NOT EXISTS xonstat.games_2021q2 ( + CHECK ( create_dt >= DATE '2021-04-01' AND create_dt < DATE '2021-07-01' ) +) INHERITS (games); + +CREATE INDEX games_2021q2_ix001 on games_2021q2(create_dt); +CREATE INDEX games_2021q2_ix002 on games_2021q2 using gin(players); +CREATE UNIQUE INDEX games_2021q2_pk on games_2021q2(game_id); +ALTER TABLE games_2021q2 ADD PRIMARY KEY USING INDEX games_2021q2_pk; + +CREATE TABLE IF NOT EXISTS xonstat.games_2021q3 ( + CHECK ( create_dt >= DATE '2021-07-01' AND create_dt < DATE '2021-10-01' ) +) INHERITS (games); + +CREATE INDEX games_2021q3_ix001 on games_2021q3(create_dt); +CREATE INDEX games_2021q3_ix002 on games_2021q3 using gin(players); +CREATE UNIQUE INDEX games_2021q3_pk on games_2021q3(game_id); +ALTER TABLE games_2021q3 ADD PRIMARY KEY USING INDEX games_2021q3_pk; + +CREATE TABLE IF NOT EXISTS xonstat.games_2021q4 ( + CHECK ( create_dt >= DATE '2021-10-01' AND create_dt < DATE '2022-01-01' ) +) INHERITS (games); + +CREATE INDEX games_2021q4_ix001 on games_2021q4(create_dt); +CREATE INDEX games_2021q4_ix002 on games_2021q4 using gin(players); +CREATE UNIQUE INDEX games_2021q4_pk on games_2021q4(game_id); +ALTER TABLE games_2021q4 ADD PRIMARY KEY USING INDEX games_2021q4_pk; + +CREATE TABLE IF NOT EXISTS xonstat.games_2022q1 ( + CHECK ( create_dt >= DATE '2022-01-01' AND create_dt < DATE '2022-04-01' ) +) INHERITS (games); + +CREATE INDEX games_2022q1_ix001 on games_2022q1(create_dt); +CREATE INDEX games_2022q1_ix002 on games_2022q1 using gin(players); +CREATE UNIQUE INDEX games_2022q1_pk on games_2022q1(game_id); +ALTER TABLE games_2022q1 ADD PRIMARY KEY USING INDEX games_2022q1_pk; + +CREATE TABLE IF NOT EXISTS xonstat.games_2022q2 ( + CHECK ( create_dt >= DATE '2022-04-01' AND create_dt < DATE '2022-07-01' ) +) INHERITS (games); + +CREATE INDEX games_2022q2_ix001 on games_2022q2(create_dt); +CREATE INDEX games_2022q2_ix002 on games_2022q2 using gin(players); +CREATE UNIQUE INDEX games_2022q2_pk on games_2022q2(game_id); +ALTER TABLE games_2022q2 ADD PRIMARY KEY USING INDEX games_2022q2_pk; + +CREATE TABLE IF NOT EXISTS xonstat.games_2022q3 ( + CHECK ( create_dt >= DATE '2022-07-01' AND create_dt < DATE '2022-10-01' ) +) INHERITS (games); + +CREATE INDEX games_2022q3_ix001 on games_2022q3(create_dt); +CREATE INDEX games_2022q3_ix002 on games_2022q3 using gin(players); +CREATE UNIQUE INDEX games_2022q3_pk on games_2022q3(game_id); +ALTER TABLE games_2022q3 ADD PRIMARY KEY USING INDEX games_2022q3_pk; + +CREATE TABLE IF NOT EXISTS xonstat.games_2022q4 ( + CHECK ( create_dt >= DATE '2022-10-01' AND create_dt < DATE '2023-01-01' ) +) INHERITS (games); + +CREATE INDEX games_2022q4_ix001 on games_2022q4(create_dt); +CREATE INDEX games_2022q4_ix002 on games_2022q4 using gin(players); +CREATE UNIQUE INDEX games_2022q4_pk on games_2022q4(game_id); +ALTER TABLE games_2022q4 ADD PRIMARY KEY USING INDEX games_2022q4_pk; + +CREATE TABLE IF NOT EXISTS xonstat.games_2023q1 ( + CHECK ( create_dt >= DATE '2023-01-01' AND create_dt < DATE '2023-04-01' ) +) INHERITS (games); + +CREATE INDEX games_2023q1_ix001 on games_2023q1(create_dt); +CREATE INDEX games_2023q1_ix002 on games_2023q1 using gin(players); +CREATE UNIQUE INDEX games_2023q1_pk on games_2023q1(game_id); +ALTER TABLE games_2023q1 ADD PRIMARY KEY USING INDEX games_2023q1_pk; + +CREATE TABLE IF NOT EXISTS xonstat.games_2023q2 ( + CHECK ( create_dt >= DATE '2023-04-01' AND create_dt < DATE '2023-07-01' ) +) INHERITS (games); + +CREATE INDEX games_2023q2_ix001 on games_2023q2(create_dt); +CREATE INDEX games_2023q2_ix002 on games_2023q2 using gin(players); +CREATE UNIQUE INDEX games_2023q2_pk on games_2023q2(game_id); +ALTER TABLE games_2023q2 ADD PRIMARY KEY USING INDEX games_2023q2_pk; + +CREATE TABLE IF NOT EXISTS xonstat.games_2023q3 ( + CHECK ( create_dt >= DATE '2023-07-01' AND create_dt < DATE '2023-10-01' ) +) INHERITS (games); + +CREATE INDEX games_2023q3_ix001 on games_2023q3(create_dt); +CREATE INDEX games_2023q3_ix002 on games_2023q3 using gin(players); +CREATE UNIQUE INDEX games_2023q3_pk on games_2023q3(game_id); +ALTER TABLE games_2023q3 ADD PRIMARY KEY USING INDEX games_2023q3_pk; + +CREATE TABLE IF NOT EXISTS xonstat.games_2023q4 ( + CHECK ( create_dt >= DATE '2023-10-01' AND create_dt < DATE '2024-01-01' ) +) INHERITS (games); + +CREATE INDEX games_2023q4_ix001 on games_2023q4(create_dt); +CREATE INDEX games_2023q4_ix002 on games_2023q4 using gin(players); +CREATE UNIQUE INDEX games_2023q4_pk on games_2023q4(game_id); +ALTER TABLE games_2023q4 ADD PRIMARY KEY USING INDEX games_2023q4_pk; + +CREATE TABLE IF NOT EXISTS xonstat.games_2024q1 ( + CHECK ( create_dt >= DATE '2024-01-01' AND create_dt < DATE '2024-04-01' ) +) INHERITS (games); + +CREATE INDEX games_2024q1_ix001 on games_2024q1(create_dt); +CREATE INDEX games_2024q1_ix002 on games_2024q1 using gin(players); +CREATE UNIQUE INDEX games_2024q1_pk on games_2024q1(game_id); +ALTER TABLE games_2024q1 ADD PRIMARY KEY USING INDEX games_2024q1_pk; + +CREATE TABLE IF NOT EXISTS xonstat.games_2024q2 ( + CHECK ( create_dt >= DATE '2024-04-01' AND create_dt < DATE '2024-07-01' ) +) INHERITS (games); + +CREATE INDEX games_2024q2_ix001 on games_2024q2(create_dt); +CREATE INDEX games_2024q2_ix002 on games_2024q2 using gin(players); +CREATE UNIQUE INDEX games_2024q2_pk on games_2024q2(game_id); +ALTER TABLE games_2024q2 ADD PRIMARY KEY USING INDEX games_2024q2_pk; + +CREATE TABLE IF NOT EXISTS xonstat.games_2024q3 ( + CHECK ( create_dt >= DATE '2024-07-01' AND create_dt < DATE '2024-10-01' ) +) INHERITS (games); + +CREATE INDEX games_2024q3_ix001 on games_2024q3(create_dt); +CREATE INDEX games_2024q3_ix002 on games_2024q3 using gin(players); +CREATE UNIQUE INDEX games_2024q3_pk on games_2024q3(game_id); +ALTER TABLE games_2024q3 ADD PRIMARY KEY USING INDEX games_2024q3_pk; + +CREATE TABLE IF NOT EXISTS xonstat.games_2024q4 ( + CHECK ( create_dt >= DATE '2024-10-01' AND create_dt < DATE '2025-01-01' ) +) INHERITS (games); + +CREATE INDEX games_2024q4_ix001 on games_2024q4(create_dt); +CREATE INDEX games_2024q4_ix002 on games_2024q4 using gin(players); +CREATE UNIQUE INDEX games_2024q4_pk on games_2024q4(game_id); +ALTER TABLE games_2024q4 ADD PRIMARY KEY USING INDEX games_2024q4_pk; + +CREATE TABLE IF NOT EXISTS xonstat.games_2025q1 ( + CHECK ( create_dt >= DATE '2025-01-01' AND create_dt < DATE '2025-04-01' ) +) INHERITS (games); + +CREATE INDEX games_2025q1_ix001 on games_2025q1(create_dt); +CREATE INDEX games_2025q1_ix002 on games_2025q1 using gin(players); +CREATE UNIQUE INDEX games_2025q1_pk on games_2025q1(game_id); +ALTER TABLE games_2025q1 ADD PRIMARY KEY USING INDEX games_2025q1_pk; + +CREATE TABLE IF NOT EXISTS xonstat.games_2025q2 ( + CHECK ( create_dt >= DATE '2025-04-01' AND create_dt < DATE '2025-07-01' ) +) INHERITS (games); + +CREATE INDEX games_2025q2_ix001 on games_2025q2(create_dt); +CREATE INDEX games_2025q2_ix002 on games_2025q2 using gin(players); +CREATE UNIQUE INDEX games_2025q2_pk on games_2025q2(game_id); +ALTER TABLE games_2025q2 ADD PRIMARY KEY USING INDEX games_2025q2_pk; + +CREATE TABLE IF NOT EXISTS xonstat.games_2025q3 ( + CHECK ( create_dt >= DATE '2025-07-01' AND create_dt < DATE '2025-10-01' ) +) INHERITS (games); + +CREATE INDEX games_2025q3_ix001 on games_2025q3(create_dt); +CREATE INDEX games_2025q3_ix002 on games_2025q3 using gin(players); +CREATE UNIQUE INDEX games_2025q3_pk on games_2025q3(game_id); +ALTER TABLE games_2025q3 ADD PRIMARY KEY USING INDEX games_2025q3_pk; + +CREATE TABLE IF NOT EXISTS xonstat.games_2025q4 ( + CHECK ( create_dt >= DATE '2025-10-01' AND create_dt < DATE '2026-01-01' ) +) INHERITS (games); + +CREATE INDEX games_2025q4_ix001 on games_2025q4(create_dt); +CREATE INDEX games_2025q4_ix002 on games_2025q4 using gin(players); +CREATE UNIQUE INDEX games_2025q4_pk on games_2025q4(game_id); +ALTER TABLE games_2025q4 ADD PRIMARY KEY USING INDEX games_2025q4_pk; + diff --git a/tables/player_game_frag_matrix.tab b/tables/player_game_frag_matrix.tab index c41b79b..f27834c 100755 --- a/tables/player_game_frag_matrix.tab +++ b/tables/player_game_frag_matrix.tab @@ -123,3 +123,124 @@ CREATE TABLE IF NOT EXISTS xonstat.player_game_frag_matrix_2020q4 ( CREATE INDEX player_game_frag_matrix_2020q4_ix001 on player_game_frag_matrix_2020q4(create_dt); CREATE INDEX player_game_frag_matrix_2020q4_ix002 on player_game_frag_matrix_2020q4(game_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_frag_matrix_2021q1 ( + CHECK ( create_dt >= DATE '2021-01-01' AND create_dt < DATE '2021-04-01' ) +) INHERITS (player_game_frag_matrix); + +CREATE INDEX player_game_frag_matrix_2021q1_ix001 on player_game_frag_matrix_2021q1(create_dt); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_frag_matrix_2021q2 ( + CHECK ( create_dt >= DATE '2021-04-01' AND create_dt < DATE '2021-07-01' ) +) INHERITS (player_game_frag_matrix); + +CREATE INDEX player_game_frag_matrix_2021q2_ix001 on player_game_frag_matrix_2021q2(create_dt); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_frag_matrix_2021q3 ( + CHECK ( create_dt >= DATE '2021-07-01' AND create_dt < DATE '2021-10-01' ) +) INHERITS (player_game_frag_matrix); + +CREATE INDEX player_game_frag_matrix_2021q3_ix001 on player_game_frag_matrix_2021q3(create_dt); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_frag_matrix_2021q4 ( + CHECK ( create_dt >= DATE '2021-10-01' AND create_dt < DATE '2022-01-01' ) +) INHERITS (player_game_frag_matrix); + +CREATE INDEX player_game_frag_matrix_2021q4_ix001 on player_game_frag_matrix_2021q4(create_dt); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_frag_matrix_2022q1 ( + CHECK ( create_dt >= DATE '2022-01-01' AND create_dt < DATE '2022-04-01' ) +) INHERITS (player_game_frag_matrix); + +CREATE INDEX player_game_frag_matrix_2022q1_ix001 on player_game_frag_matrix_2022q1(create_dt); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_frag_matrix_2022q2 ( + CHECK ( create_dt >= DATE '2022-04-01' AND create_dt < DATE '2022-07-01' ) +) INHERITS (player_game_frag_matrix); + +CREATE INDEX player_game_frag_matrix_2022q2_ix001 on player_game_frag_matrix_2022q2(create_dt); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_frag_matrix_2022q3 ( + CHECK ( create_dt >= DATE '2022-07-01' AND create_dt < DATE '2022-10-01' ) +) INHERITS (player_game_frag_matrix); + +CREATE INDEX player_game_frag_matrix_2022q3_ix001 on player_game_frag_matrix_2022q3(create_dt); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_frag_matrix_2022q4 ( + CHECK ( create_dt >= DATE '2022-10-01' AND create_dt < DATE '2023-01-01' ) +) INHERITS (player_game_frag_matrix); + +CREATE INDEX player_game_frag_matrix_2022q4_ix001 on player_game_frag_matrix_2022q4(create_dt); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_frag_matrix_2023q1 ( + CHECK ( create_dt >= DATE '2023-01-01' AND create_dt < DATE '2023-04-01' ) +) INHERITS (player_game_frag_matrix); + +CREATE INDEX player_game_frag_matrix_2023q1_ix001 on player_game_frag_matrix_2023q1(create_dt); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_frag_matrix_2023q2 ( + CHECK ( create_dt >= DATE '2023-04-01' AND create_dt < DATE '2023-07-01' ) +) INHERITS (player_game_frag_matrix); + +CREATE INDEX player_game_frag_matrix_2023q2_ix001 on player_game_frag_matrix_2023q2(create_dt); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_frag_matrix_2023q3 ( + CHECK ( create_dt >= DATE '2023-07-01' AND create_dt < DATE '2023-10-01' ) +) INHERITS (player_game_frag_matrix); + +CREATE INDEX player_game_frag_matrix_2023q3_ix001 on player_game_frag_matrix_2023q3(create_dt); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_frag_matrix_2023q4 ( + CHECK ( create_dt >= DATE '2023-10-01' AND create_dt < DATE '2024-01-01' ) +) INHERITS (player_game_frag_matrix); + +CREATE INDEX player_game_frag_matrix_2023q4_ix001 on player_game_frag_matrix_2023q4(create_dt); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_frag_matrix_2024q1 ( + CHECK ( create_dt >= DATE '2024-01-01' AND create_dt < DATE '2024-04-01' ) +) INHERITS (player_game_frag_matrix); + +CREATE INDEX player_game_frag_matrix_2024q1_ix001 on player_game_frag_matrix_2024q1(create_dt); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_frag_matrix_2024q2 ( + CHECK ( create_dt >= DATE '2024-04-01' AND create_dt < DATE '2024-07-01' ) +) INHERITS (player_game_frag_matrix); + +CREATE INDEX player_game_frag_matrix_2024q2_ix001 on player_game_frag_matrix_2024q2(create_dt); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_frag_matrix_2024q3 ( + CHECK ( create_dt >= DATE '2024-07-01' AND create_dt < DATE '2024-10-01' ) +) INHERITS (player_game_frag_matrix); + +CREATE INDEX player_game_frag_matrix_2024q3_ix001 on player_game_frag_matrix_2024q3(create_dt); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_frag_matrix_2024q4 ( + CHECK ( create_dt >= DATE '2024-10-01' AND create_dt < DATE '2025-01-01' ) +) INHERITS (player_game_frag_matrix); + +CREATE INDEX player_game_frag_matrix_2024q4_ix001 on player_game_frag_matrix_2024q4(create_dt); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_frag_matrix_2025q1 ( + CHECK ( create_dt >= DATE '2025-01-01' AND create_dt < DATE '2025-04-01' ) +) INHERITS (player_game_frag_matrix); + +CREATE INDEX player_game_frag_matrix_2025q1_ix001 on player_game_frag_matrix_2025q1(create_dt); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_frag_matrix_2025q2 ( + CHECK ( create_dt >= DATE '2025-04-01' AND create_dt < DATE '2025-07-01' ) +) INHERITS (player_game_frag_matrix); + +CREATE INDEX player_game_frag_matrix_2025q2_ix001 on player_game_frag_matrix_2025q2(create_dt); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_frag_matrix_2025q3 ( + CHECK ( create_dt >= DATE '2025-07-01' AND create_dt < DATE '2025-10-01' ) +) INHERITS (player_game_frag_matrix); + +CREATE INDEX player_game_frag_matrix_2025q3_ix001 on player_game_frag_matrix_2025q3(create_dt); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_frag_matrix_2025q4 ( + CHECK ( create_dt >= DATE '2025-10-01' AND create_dt < DATE '2026-01-01' ) +) INHERITS (player_game_frag_matrix); + +CREATE INDEX player_game_frag_matrix_2025q4_ix001 on player_game_frag_matrix_2025q4(create_dt); + diff --git a/tables/player_game_nonparticipants.tab b/tables/player_game_nonparticipants.tab index 3919d65..07b0802 100755 --- a/tables/player_game_nonparticipants.tab +++ b/tables/player_game_nonparticipants.tab @@ -21,10 +21,10 @@ WITH ( OIDS=FALSE ); -CREATE INDEX player_game_nonparticipant_ix01 on player_game_nonparticipantss(create_dt); -CREATE INDEX player_game_nonparticipant_ix02 on player_game_nonparticipantss(game_id); -CREATE INDEX player_game_nonparticipant_ix03 on player_game_nonparticipantss(player_id); -ALTER TABLE xonstat.player_game_stats OWNER TO xonstat; +CREATE INDEX player_game_nonparticipant_ix01 on player_game_nonparticipants(create_dt); +CREATE INDEX player_game_nonparticipant_ix02 on player_game_nonparticipants(game_id); +CREATE INDEX player_game_nonparticipant_ix03 on player_game_nonparticipants(player_id); +ALTER TABLE xonstat.player_game_nonparticipants OWNER TO xonstat; CREATE TABLE IF NOT EXISTS xonstat.player_game_nonparticipants_2020q4 ( CHECK ( create_dt >= DATE '2020-10-01' AND create_dt < DATE '2021-01-01' ) diff --git a/tables/player_game_stats.tab b/tables/player_game_stats.tab index 7b124fe..ee937ed 100755 --- a/tables/player_game_stats.tab +++ b/tables/player_game_stats.tab @@ -270,3 +270,165 @@ CREATE TABLE IF NOT EXISTS xonstat.player_game_stats_2020q4 ( CREATE INDEX player_game_stats_2020q4_ix001 on player_game_stats_2020q4(create_dt); CREATE INDEX player_game_stats_2020q4_ix002 on player_game_stats_2020q4(game_id); CREATE INDEX player_game_stats_2020q4_ix003 on player_game_stats_2020q4(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_stats_2021q1 ( + CHECK ( create_dt >= DATE '2021-01-01' AND create_dt < DATE '2021-04-01' ) +) INHERITS (player_game_stats); + +CREATE INDEX player_game_stats_2021q1_ix001 on player_game_stats_2021q1(create_dt); +CREATE INDEX player_game_stats_2021q1_ix002 on player_game_stats_2021q1(game_id); +CREATE INDEX player_game_stats_2021q1_ix003 on player_game_stats_2021q1(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_stats_2021q2 ( + CHECK ( create_dt >= DATE '2021-04-01' AND create_dt < DATE '2021-07-01' ) +) INHERITS (player_game_stats); + +CREATE INDEX player_game_stats_2021q2_ix001 on player_game_stats_2021q2(create_dt); +CREATE INDEX player_game_stats_2021q2_ix002 on player_game_stats_2021q2(game_id); +CREATE INDEX player_game_stats_2021q2_ix003 on player_game_stats_2021q2(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_stats_2021q3 ( + CHECK ( create_dt >= DATE '2021-07-01' AND create_dt < DATE '2021-10-01' ) +) INHERITS (player_game_stats); + +CREATE INDEX player_game_stats_2021q3_ix001 on player_game_stats_2021q3(create_dt); +CREATE INDEX player_game_stats_2021q3_ix002 on player_game_stats_2021q3(game_id); +CREATE INDEX player_game_stats_2021q3_ix003 on player_game_stats_2021q3(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_stats_2021q4 ( + CHECK ( create_dt >= DATE '2021-10-01' AND create_dt < DATE '2022-01-01' ) +) INHERITS (player_game_stats); + +CREATE INDEX player_game_stats_2021q4_ix001 on player_game_stats_2021q4(create_dt); +CREATE INDEX player_game_stats_2021q4_ix002 on player_game_stats_2021q4(game_id); +CREATE INDEX player_game_stats_2021q4_ix003 on player_game_stats_2021q4(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_stats_2022q1 ( + CHECK ( create_dt >= DATE '2022-01-01' AND create_dt < DATE '2022-04-01' ) +) INHERITS (player_game_stats); + +CREATE INDEX player_game_stats_2022q1_ix001 on player_game_stats_2022q1(create_dt); +CREATE INDEX player_game_stats_2022q1_ix002 on player_game_stats_2022q1(game_id); +CREATE INDEX player_game_stats_2022q1_ix003 on player_game_stats_2022q1(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_stats_2022q2 ( + CHECK ( create_dt >= DATE '2022-04-01' AND create_dt < DATE '2022-07-01' ) +) INHERITS (player_game_stats); + +CREATE INDEX player_game_stats_2022q2_ix001 on player_game_stats_2022q2(create_dt); +CREATE INDEX player_game_stats_2022q2_ix002 on player_game_stats_2022q2(game_id); +CREATE INDEX player_game_stats_2022q2_ix003 on player_game_stats_2022q2(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_stats_2022q3 ( + CHECK ( create_dt >= DATE '2022-07-01' AND create_dt < DATE '2022-10-01' ) +) INHERITS (player_game_stats); + +CREATE INDEX player_game_stats_2022q3_ix001 on player_game_stats_2022q3(create_dt); +CREATE INDEX player_game_stats_2022q3_ix002 on player_game_stats_2022q3(game_id); +CREATE INDEX player_game_stats_2022q3_ix003 on player_game_stats_2022q3(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_stats_2022q4 ( + CHECK ( create_dt >= DATE '2022-10-01' AND create_dt < DATE '2023-01-01' ) +) INHERITS (player_game_stats); + +CREATE INDEX player_game_stats_2022q4_ix001 on player_game_stats_2022q4(create_dt); +CREATE INDEX player_game_stats_2022q4_ix002 on player_game_stats_2022q4(game_id); +CREATE INDEX player_game_stats_2022q4_ix003 on player_game_stats_2022q4(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_stats_2023q1 ( + CHECK ( create_dt >= DATE '2023-01-01' AND create_dt < DATE '2023-04-01' ) +) INHERITS (player_game_stats); + +CREATE INDEX player_game_stats_2023q1_ix001 on player_game_stats_2023q1(create_dt); +CREATE INDEX player_game_stats_2023q1_ix002 on player_game_stats_2023q1(game_id); +CREATE INDEX player_game_stats_2023q1_ix003 on player_game_stats_2023q1(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_stats_2023q2 ( + CHECK ( create_dt >= DATE '2023-04-01' AND create_dt < DATE '2023-07-01' ) +) INHERITS (player_game_stats); + +CREATE INDEX player_game_stats_2023q2_ix001 on player_game_stats_2023q2(create_dt); +CREATE INDEX player_game_stats_2023q2_ix002 on player_game_stats_2023q2(game_id); +CREATE INDEX player_game_stats_2023q2_ix003 on player_game_stats_2023q2(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_stats_2023q3 ( + CHECK ( create_dt >= DATE '2023-07-01' AND create_dt < DATE '2023-10-01' ) +) INHERITS (player_game_stats); + +CREATE INDEX player_game_stats_2023q3_ix001 on player_game_stats_2023q3(create_dt); +CREATE INDEX player_game_stats_2023q3_ix002 on player_game_stats_2023q3(game_id); +CREATE INDEX player_game_stats_2023q3_ix003 on player_game_stats_2023q3(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_stats_2023q4 ( + CHECK ( create_dt >= DATE '2023-10-01' AND create_dt < DATE '2024-01-01' ) +) INHERITS (player_game_stats); + +CREATE INDEX player_game_stats_2023q4_ix001 on player_game_stats_2023q4(create_dt); +CREATE INDEX player_game_stats_2023q4_ix002 on player_game_stats_2023q4(game_id); +CREATE INDEX player_game_stats_2023q4_ix003 on player_game_stats_2023q4(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_stats_2024q1 ( + CHECK ( create_dt >= DATE '2024-01-01' AND create_dt < DATE '2024-04-01' ) +) INHERITS (player_game_stats); + +CREATE INDEX player_game_stats_2024q1_ix001 on player_game_stats_2024q1(create_dt); +CREATE INDEX player_game_stats_2024q1_ix002 on player_game_stats_2024q1(game_id); +CREATE INDEX player_game_stats_2024q1_ix003 on player_game_stats_2024q1(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_stats_2024q2 ( + CHECK ( create_dt >= DATE '2024-04-01' AND create_dt < DATE '2024-07-01' ) +) INHERITS (player_game_stats); + +CREATE INDEX player_game_stats_2024q2_ix001 on player_game_stats_2024q2(create_dt); +CREATE INDEX player_game_stats_2024q2_ix002 on player_game_stats_2024q2(game_id); +CREATE INDEX player_game_stats_2024q2_ix003 on player_game_stats_2024q2(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_stats_2024q3 ( + CHECK ( create_dt >= DATE '2024-07-01' AND create_dt < DATE '2024-10-01' ) +) INHERITS (player_game_stats); + +CREATE INDEX player_game_stats_2024q3_ix001 on player_game_stats_2024q3(create_dt); +CREATE INDEX player_game_stats_2024q3_ix002 on player_game_stats_2024q3(game_id); +CREATE INDEX player_game_stats_2024q3_ix003 on player_game_stats_2024q3(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_stats_2024q4 ( + CHECK ( create_dt >= DATE '2024-10-01' AND create_dt < DATE '2025-01-01' ) +) INHERITS (player_game_stats); + +CREATE INDEX player_game_stats_2024q4_ix001 on player_game_stats_2024q4(create_dt); +CREATE INDEX player_game_stats_2024q4_ix002 on player_game_stats_2024q4(game_id); +CREATE INDEX player_game_stats_2024q4_ix003 on player_game_stats_2024q4(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_stats_2025q1 ( + CHECK ( create_dt >= DATE '2025-01-01' AND create_dt < DATE '2025-04-01' ) +) INHERITS (player_game_stats); + +CREATE INDEX player_game_stats_2025q1_ix001 on player_game_stats_2025q1(create_dt); +CREATE INDEX player_game_stats_2025q1_ix002 on player_game_stats_2025q1(game_id); +CREATE INDEX player_game_stats_2025q1_ix003 on player_game_stats_2025q1(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_stats_2025q2 ( + CHECK ( create_dt >= DATE '2025-04-01' AND create_dt < DATE '2025-07-01' ) +) INHERITS (player_game_stats); + +CREATE INDEX player_game_stats_2025q2_ix001 on player_game_stats_2025q2(create_dt); +CREATE INDEX player_game_stats_2025q2_ix002 on player_game_stats_2025q2(game_id); +CREATE INDEX player_game_stats_2025q2_ix003 on player_game_stats_2025q2(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_stats_2025q3 ( + CHECK ( create_dt >= DATE '2025-07-01' AND create_dt < DATE '2025-10-01' ) +) INHERITS (player_game_stats); + +CREATE INDEX player_game_stats_2025q3_ix001 on player_game_stats_2025q3(create_dt); +CREATE INDEX player_game_stats_2025q3_ix002 on player_game_stats_2025q3(game_id); +CREATE INDEX player_game_stats_2025q3_ix003 on player_game_stats_2025q3(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_game_stats_2025q4 ( + CHECK ( create_dt >= DATE '2025-10-01' AND create_dt < DATE '2026-01-01' ) +) INHERITS (player_game_stats); + +CREATE INDEX player_game_stats_2025q4_ix001 on player_game_stats_2025q4(create_dt); +CREATE INDEX player_game_stats_2025q4_ix002 on player_game_stats_2025q4(game_id); +CREATE INDEX player_game_stats_2025q4_ix003 on player_game_stats_2025q4(player_id); + + diff --git a/tables/player_weapon_stats.tab b/tables/player_weapon_stats.tab index f5bbb03..ab041d4 100755 --- a/tables/player_weapon_stats.tab +++ b/tables/player_weapon_stats.tab @@ -258,3 +258,165 @@ CREATE TABLE IF NOT EXISTS xonstat.player_weapon_stats_2020q4 ( CREATE INDEX player_weapon_stats_2020q4_ix001 on player_weapon_stats_2020q4(create_dt); CREATE INDEX player_weapon_stats_2020q4_ix002 on player_weapon_stats_2020q4(game_id); CREATE INDEX player_weapon_stats_2020q4_ix003 on player_weapon_stats_2020q4(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_weapon_stats_2021q1 ( + CHECK ( create_dt >= DATE '2021-01-01' AND create_dt < DATE '2021-04-01' ) +) INHERITS (player_weapon_stats); + +CREATE INDEX player_weapon_stats_2021q1_ix001 on player_weapon_stats_2021q1(create_dt); +CREATE INDEX player_weapon_stats_2021q1_ix002 on player_weapon_stats_2021q1(game_id); +CREATE INDEX player_weapon_stats_2021q1_ix003 on player_weapon_stats_2021q1(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_weapon_stats_2021q2 ( + CHECK ( create_dt >= DATE '2021-04-01' AND create_dt < DATE '2021-07-01' ) +) INHERITS (player_weapon_stats); + +CREATE INDEX player_weapon_stats_2021q2_ix001 on player_weapon_stats_2021q2(create_dt); +CREATE INDEX player_weapon_stats_2021q2_ix002 on player_weapon_stats_2021q2(game_id); +CREATE INDEX player_weapon_stats_2021q2_ix003 on player_weapon_stats_2021q2(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_weapon_stats_2021q3 ( + CHECK ( create_dt >= DATE '2021-07-01' AND create_dt < DATE '2021-10-01' ) +) INHERITS (player_weapon_stats); + +CREATE INDEX player_weapon_stats_2021q3_ix001 on player_weapon_stats_2021q3(create_dt); +CREATE INDEX player_weapon_stats_2021q3_ix002 on player_weapon_stats_2021q3(game_id); +CREATE INDEX player_weapon_stats_2021q3_ix003 on player_weapon_stats_2021q3(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_weapon_stats_2021q4 ( + CHECK ( create_dt >= DATE '2021-10-01' AND create_dt < DATE '2022-01-01' ) +) INHERITS (player_weapon_stats); + +CREATE INDEX player_weapon_stats_2021q4_ix001 on player_weapon_stats_2021q4(create_dt); +CREATE INDEX player_weapon_stats_2021q4_ix002 on player_weapon_stats_2021q4(game_id); +CREATE INDEX player_weapon_stats_2021q4_ix003 on player_weapon_stats_2021q4(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_weapon_stats_2022q1 ( + CHECK ( create_dt >= DATE '2022-01-01' AND create_dt < DATE '2022-04-01' ) +) INHERITS (player_weapon_stats); + +CREATE INDEX player_weapon_stats_2022q1_ix001 on player_weapon_stats_2022q1(create_dt); +CREATE INDEX player_weapon_stats_2022q1_ix002 on player_weapon_stats_2022q1(game_id); +CREATE INDEX player_weapon_stats_2022q1_ix003 on player_weapon_stats_2022q1(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_weapon_stats_2022q2 ( + CHECK ( create_dt >= DATE '2022-04-01' AND create_dt < DATE '2022-07-01' ) +) INHERITS (player_weapon_stats); + +CREATE INDEX player_weapon_stats_2022q2_ix001 on player_weapon_stats_2022q2(create_dt); +CREATE INDEX player_weapon_stats_2022q2_ix002 on player_weapon_stats_2022q2(game_id); +CREATE INDEX player_weapon_stats_2022q2_ix003 on player_weapon_stats_2022q2(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_weapon_stats_2022q3 ( + CHECK ( create_dt >= DATE '2022-07-01' AND create_dt < DATE '2022-10-01' ) +) INHERITS (player_weapon_stats); + +CREATE INDEX player_weapon_stats_2022q3_ix001 on player_weapon_stats_2022q3(create_dt); +CREATE INDEX player_weapon_stats_2022q3_ix002 on player_weapon_stats_2022q3(game_id); +CREATE INDEX player_weapon_stats_2022q3_ix003 on player_weapon_stats_2022q3(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_weapon_stats_2022q4 ( + CHECK ( create_dt >= DATE '2022-10-01' AND create_dt < DATE '2023-01-01' ) +) INHERITS (player_weapon_stats); + +CREATE INDEX player_weapon_stats_2022q4_ix001 on player_weapon_stats_2022q4(create_dt); +CREATE INDEX player_weapon_stats_2022q4_ix002 on player_weapon_stats_2022q4(game_id); +CREATE INDEX player_weapon_stats_2022q4_ix003 on player_weapon_stats_2022q4(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_weapon_stats_2023q1 ( + CHECK ( create_dt >= DATE '2023-01-01' AND create_dt < DATE '2023-04-01' ) +) INHERITS (player_weapon_stats); + +CREATE INDEX player_weapon_stats_2023q1_ix001 on player_weapon_stats_2023q1(create_dt); +CREATE INDEX player_weapon_stats_2023q1_ix002 on player_weapon_stats_2023q1(game_id); +CREATE INDEX player_weapon_stats_2023q1_ix003 on player_weapon_stats_2023q1(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_weapon_stats_2023q2 ( + CHECK ( create_dt >= DATE '2023-04-01' AND create_dt < DATE '2023-07-01' ) +) INHERITS (player_weapon_stats); + +CREATE INDEX player_weapon_stats_2023q2_ix001 on player_weapon_stats_2023q2(create_dt); +CREATE INDEX player_weapon_stats_2023q2_ix002 on player_weapon_stats_2023q2(game_id); +CREATE INDEX player_weapon_stats_2023q2_ix003 on player_weapon_stats_2023q2(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_weapon_stats_2023q3 ( + CHECK ( create_dt >= DATE '2023-07-01' AND create_dt < DATE '2023-10-01' ) +) INHERITS (player_weapon_stats); + +CREATE INDEX player_weapon_stats_2023q3_ix001 on player_weapon_stats_2023q3(create_dt); +CREATE INDEX player_weapon_stats_2023q3_ix002 on player_weapon_stats_2023q3(game_id); +CREATE INDEX player_weapon_stats_2023q3_ix003 on player_weapon_stats_2023q3(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_weapon_stats_2023q4 ( + CHECK ( create_dt >= DATE '2023-10-01' AND create_dt < DATE '2024-01-01' ) +) INHERITS (player_weapon_stats); + +CREATE INDEX player_weapon_stats_2023q4_ix001 on player_weapon_stats_2023q4(create_dt); +CREATE INDEX player_weapon_stats_2023q4_ix002 on player_weapon_stats_2023q4(game_id); +CREATE INDEX player_weapon_stats_2023q4_ix003 on player_weapon_stats_2023q4(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_weapon_stats_2024q1 ( + CHECK ( create_dt >= DATE '2024-01-01' AND create_dt < DATE '2024-04-01' ) +) INHERITS (player_weapon_stats); + +CREATE INDEX player_weapon_stats_2024q1_ix001 on player_weapon_stats_2024q1(create_dt); +CREATE INDEX player_weapon_stats_2024q1_ix002 on player_weapon_stats_2024q1(game_id); +CREATE INDEX player_weapon_stats_2024q1_ix003 on player_weapon_stats_2024q1(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_weapon_stats_2024q2 ( + CHECK ( create_dt >= DATE '2024-04-01' AND create_dt < DATE '2024-07-01' ) +) INHERITS (player_weapon_stats); + +CREATE INDEX player_weapon_stats_2024q2_ix001 on player_weapon_stats_2024q2(create_dt); +CREATE INDEX player_weapon_stats_2024q2_ix002 on player_weapon_stats_2024q2(game_id); +CREATE INDEX player_weapon_stats_2024q2_ix003 on player_weapon_stats_2024q2(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_weapon_stats_2024q3 ( + CHECK ( create_dt >= DATE '2024-07-01' AND create_dt < DATE '2024-10-01' ) +) INHERITS (player_weapon_stats); + +CREATE INDEX player_weapon_stats_2024q3_ix001 on player_weapon_stats_2024q3(create_dt); +CREATE INDEX player_weapon_stats_2024q3_ix002 on player_weapon_stats_2024q3(game_id); +CREATE INDEX player_weapon_stats_2024q3_ix003 on player_weapon_stats_2024q3(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_weapon_stats_2024q4 ( + CHECK ( create_dt >= DATE '2024-10-01' AND create_dt < DATE '2025-01-01' ) +) INHERITS (player_weapon_stats); + +CREATE INDEX player_weapon_stats_2024q4_ix001 on player_weapon_stats_2024q4(create_dt); +CREATE INDEX player_weapon_stats_2024q4_ix002 on player_weapon_stats_2024q4(game_id); +CREATE INDEX player_weapon_stats_2024q4_ix003 on player_weapon_stats_2024q4(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_weapon_stats_2025q1 ( + CHECK ( create_dt >= DATE '2025-01-01' AND create_dt < DATE '2025-04-01' ) +) INHERITS (player_weapon_stats); + +CREATE INDEX player_weapon_stats_2025q1_ix001 on player_weapon_stats_2025q1(create_dt); +CREATE INDEX player_weapon_stats_2025q1_ix002 on player_weapon_stats_2025q1(game_id); +CREATE INDEX player_weapon_stats_2025q1_ix003 on player_weapon_stats_2025q1(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_weapon_stats_2025q2 ( + CHECK ( create_dt >= DATE '2025-04-01' AND create_dt < DATE '2025-07-01' ) +) INHERITS (player_weapon_stats); + +CREATE INDEX player_weapon_stats_2025q2_ix001 on player_weapon_stats_2025q2(create_dt); +CREATE INDEX player_weapon_stats_2025q2_ix002 on player_weapon_stats_2025q2(game_id); +CREATE INDEX player_weapon_stats_2025q2_ix003 on player_weapon_stats_2025q2(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_weapon_stats_2025q3 ( + CHECK ( create_dt >= DATE '2025-07-01' AND create_dt < DATE '2025-10-01' ) +) INHERITS (player_weapon_stats); + +CREATE INDEX player_weapon_stats_2025q3_ix001 on player_weapon_stats_2025q3(create_dt); +CREATE INDEX player_weapon_stats_2025q3_ix002 on player_weapon_stats_2025q3(game_id); +CREATE INDEX player_weapon_stats_2025q3_ix003 on player_weapon_stats_2025q3(player_id); + +CREATE TABLE IF NOT EXISTS xonstat.player_weapon_stats_2025q4 ( + CHECK ( create_dt >= DATE '2025-10-01' AND create_dt < DATE '2026-01-01' ) +) INHERITS (player_weapon_stats); + +CREATE INDEX player_weapon_stats_2025q4_ix001 on player_weapon_stats_2025q4(create_dt); +CREATE INDEX player_weapon_stats_2025q4_ix002 on player_weapon_stats_2025q4(game_id); +CREATE INDEX player_weapon_stats_2025q4_ix003 on player_weapon_stats_2025q4(player_id); + + diff --git a/tables/team_game_stats.tab b/tables/team_game_stats.tab index fbe2595..f7d063a 100755 --- a/tables/team_game_stats.tab +++ b/tables/team_game_stats.tab @@ -215,3 +215,144 @@ CREATE TABLE IF NOT EXISTS xonstat.team_game_stats_2020q4 ( CREATE INDEX team_game_stats_2020q4_ix001 on team_game_stats_2020q4(create_dt); CREATE INDEX team_game_stats_2020q4_ix002 on team_game_stats_2020q4(game_id); + +CREATE TABLE IF NOT EXISTS xonstat.team_game_stats_2021q1 ( + CHECK ( create_dt >= DATE '2021-01-01' AND create_dt < DATE '2021-04-01' ) +) INHERITS (team_game_stats); + +CREATE INDEX team_game_stats_2021q1_ix001 on team_game_stats_2021q1(create_dt); +CREATE INDEX team_game_stats_2021q1_ix002 on team_game_stats_2021q1(game_id); + +CREATE TABLE IF NOT EXISTS xonstat.team_game_stats_2021q2 ( + CHECK ( create_dt >= DATE '2021-04-01' AND create_dt < DATE '2021-07-01' ) +) INHERITS (team_game_stats); + +CREATE INDEX team_game_stats_2021q2_ix001 on team_game_stats_2021q2(create_dt); +CREATE INDEX team_game_stats_2021q2_ix002 on team_game_stats_2021q2(game_id); + +CREATE TABLE IF NOT EXISTS xonstat.team_game_stats_2021q3 ( + CHECK ( create_dt >= DATE '2021-07-01' AND create_dt < DATE '2021-10-01' ) +) INHERITS (team_game_stats); + +CREATE INDEX team_game_stats_2021q3_ix001 on team_game_stats_2021q3(create_dt); +CREATE INDEX team_game_stats_2021q3_ix002 on team_game_stats_2021q3(game_id); + +CREATE TABLE IF NOT EXISTS xonstat.team_game_stats_2021q4 ( + CHECK ( create_dt >= DATE '2021-10-01' AND create_dt < DATE '2022-01-01' ) +) INHERITS (team_game_stats); + +CREATE INDEX team_game_stats_2021q4_ix001 on team_game_stats_2021q4(create_dt); +CREATE INDEX team_game_stats_2021q4_ix002 on team_game_stats_2021q4(game_id); + +CREATE TABLE IF NOT EXISTS xonstat.team_game_stats_2022q1 ( + CHECK ( create_dt >= DATE '2022-01-01' AND create_dt < DATE '2022-04-01' ) +) INHERITS (team_game_stats); + +CREATE INDEX team_game_stats_2022q1_ix001 on team_game_stats_2022q1(create_dt); +CREATE INDEX team_game_stats_2022q1_ix002 on team_game_stats_2022q1(game_id); + +CREATE TABLE IF NOT EXISTS xonstat.team_game_stats_2022q2 ( + CHECK ( create_dt >= DATE '2022-04-01' AND create_dt < DATE '2022-07-01' ) +) INHERITS (team_game_stats); + +CREATE INDEX team_game_stats_2022q2_ix001 on team_game_stats_2022q2(create_dt); +CREATE INDEX team_game_stats_2022q2_ix002 on team_game_stats_2022q2(game_id); + +CREATE TABLE IF NOT EXISTS xonstat.team_game_stats_2022q3 ( + CHECK ( create_dt >= DATE '2022-07-01' AND create_dt < DATE '2022-10-01' ) +) INHERITS (team_game_stats); + +CREATE INDEX team_game_stats_2022q3_ix001 on team_game_stats_2022q3(create_dt); +CREATE INDEX team_game_stats_2022q3_ix002 on team_game_stats_2022q3(game_id); + +CREATE TABLE IF NOT EXISTS xonstat.team_game_stats_2022q4 ( + CHECK ( create_dt >= DATE '2022-10-01' AND create_dt < DATE '2023-01-01' ) +) INHERITS (team_game_stats); + +CREATE INDEX team_game_stats_2022q4_ix001 on team_game_stats_2022q4(create_dt); +CREATE INDEX team_game_stats_2022q4_ix002 on team_game_stats_2022q4(game_id); + +CREATE TABLE IF NOT EXISTS xonstat.team_game_stats_2023q1 ( + CHECK ( create_dt >= DATE '2023-01-01' AND create_dt < DATE '2023-04-01' ) +) INHERITS (team_game_stats); + +CREATE INDEX team_game_stats_2023q1_ix001 on team_game_stats_2023q1(create_dt); +CREATE INDEX team_game_stats_2023q1_ix002 on team_game_stats_2023q1(game_id); + +CREATE TABLE IF NOT EXISTS xonstat.team_game_stats_2023q2 ( + CHECK ( create_dt >= DATE '2023-04-01' AND create_dt < DATE '2023-07-01' ) +) INHERITS (team_game_stats); + +CREATE INDEX team_game_stats_2023q2_ix001 on team_game_stats_2023q2(create_dt); +CREATE INDEX team_game_stats_2023q2_ix002 on team_game_stats_2023q2(game_id); + +CREATE TABLE IF NOT EXISTS xonstat.team_game_stats_2023q3 ( + CHECK ( create_dt >= DATE '2023-07-01' AND create_dt < DATE '2023-10-01' ) +) INHERITS (team_game_stats); + +CREATE INDEX team_game_stats_2023q3_ix001 on team_game_stats_2023q3(create_dt); +CREATE INDEX team_game_stats_2023q3_ix002 on team_game_stats_2023q3(game_id); + +CREATE TABLE IF NOT EXISTS xonstat.team_game_stats_2023q4 ( + CHECK ( create_dt >= DATE '2023-10-01' AND create_dt < DATE '2024-01-01' ) +) INHERITS (team_game_stats); + +CREATE INDEX team_game_stats_2023q4_ix001 on team_game_stats_2023q4(create_dt); +CREATE INDEX team_game_stats_2023q4_ix002 on team_game_stats_2023q4(game_id); + +CREATE TABLE IF NOT EXISTS xonstat.team_game_stats_2024q1 ( + CHECK ( create_dt >= DATE '2024-01-01' AND create_dt < DATE '2024-04-01' ) +) INHERITS (team_game_stats); + +CREATE INDEX team_game_stats_2024q1_ix001 on team_game_stats_2024q1(create_dt); +CREATE INDEX team_game_stats_2024q1_ix002 on team_game_stats_2024q1(game_id); + +CREATE TABLE IF NOT EXISTS xonstat.team_game_stats_2024q2 ( + CHECK ( create_dt >= DATE '2024-04-01' AND create_dt < DATE '2024-07-01' ) +) INHERITS (team_game_stats); + +CREATE INDEX team_game_stats_2024q2_ix001 on team_game_stats_2024q2(create_dt); +CREATE INDEX team_game_stats_2024q2_ix002 on team_game_stats_2024q2(game_id); + +CREATE TABLE IF NOT EXISTS xonstat.team_game_stats_2024q3 ( + CHECK ( create_dt >= DATE '2024-07-01' AND create_dt < DATE '2024-10-01' ) +) INHERITS (team_game_stats); + +CREATE INDEX team_game_stats_2024q3_ix001 on team_game_stats_2024q3(create_dt); +CREATE INDEX team_game_stats_2024q3_ix002 on team_game_stats_2024q3(game_id); + +CREATE TABLE IF NOT EXISTS xonstat.team_game_stats_2024q4 ( + CHECK ( create_dt >= DATE '2024-10-01' AND create_dt < DATE '2025-01-01' ) +) INHERITS (team_game_stats); + +CREATE INDEX team_game_stats_2024q4_ix001 on team_game_stats_2024q4(create_dt); +CREATE INDEX team_game_stats_2024q4_ix002 on team_game_stats_2024q4(game_id); + +CREATE TABLE IF NOT EXISTS xonstat.team_game_stats_2025q1 ( + CHECK ( create_dt >= DATE '2025-01-01' AND create_dt < DATE '2025-04-01' ) +) INHERITS (team_game_stats); + +CREATE INDEX team_game_stats_2025q1_ix001 on team_game_stats_2025q1(create_dt); +CREATE INDEX team_game_stats_2025q1_ix002 on team_game_stats_2025q1(game_id); + +CREATE TABLE IF NOT EXISTS xonstat.team_game_stats_2025q2 ( + CHECK ( create_dt >= DATE '2025-04-01' AND create_dt < DATE '2025-07-01' ) +) INHERITS (team_game_stats); + +CREATE INDEX team_game_stats_2025q2_ix001 on team_game_stats_2025q2(create_dt); +CREATE INDEX team_game_stats_2025q2_ix002 on team_game_stats_2025q2(game_id); + +CREATE TABLE IF NOT EXISTS xonstat.team_game_stats_2025q3 ( + CHECK ( create_dt >= DATE '2025-07-01' AND create_dt < DATE '2025-10-01' ) +) INHERITS (team_game_stats); + +CREATE INDEX team_game_stats_2025q3_ix001 on team_game_stats_2025q3(create_dt); +CREATE INDEX team_game_stats_2025q3_ix002 on team_game_stats_2025q3(game_id); + +CREATE TABLE IF NOT EXISTS xonstat.team_game_stats_2025q4 ( + CHECK ( create_dt >= DATE '2025-10-01' AND create_dt < DATE '2026-01-01' ) +) INHERITS (team_game_stats); + +CREATE INDEX team_game_stats_2025q4_ix001 on team_game_stats_2025q4(create_dt); +CREATE INDEX team_game_stats_2025q4_ix002 on team_game_stats_2025q4(game_id); + diff --git a/triggers/games_ins_trg.sql b/triggers/games_ins_trg.sql index 937ff09..01b286e 100644 --- a/triggers/games_ins_trg.sql +++ b/triggers/games_ins_trg.sql @@ -1,55 +1,7 @@ CREATE OR REPLACE FUNCTION games_ins() RETURNS TRIGGER AS $$ BEGIN - IF (NEW.create_dt >= DATE '2014-01-01' AND NEW.create_dt < DATE '2014-04-01') THEN - INSERT INTO games_2014Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2014-04-01' AND NEW.create_dt < DATE '2014-07-01') THEN - INSERT INTO games_2014Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2014-07-01' AND NEW.create_dt < DATE '2014-10-01') THEN - INSERT INTO games_2014Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2014-10-01' AND NEW.create_dt < DATE '2015-01-01') THEN - INSERT INTO games_2014Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2015-01-01' AND NEW.create_dt < DATE '2015-04-01') THEN - INSERT INTO games_2015Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2015-04-01' AND NEW.create_dt < DATE '2015-07-01') THEN - INSERT INTO games_2015Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2015-07-01' AND NEW.create_dt < DATE '2015-10-01') THEN - INSERT INTO games_2015Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2015-10-01' AND NEW.create_dt < DATE '2016-01-01') THEN - INSERT INTO games_2015Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2016-01-01' AND NEW.create_dt < DATE '2016-04-01') THEN - INSERT INTO games_2016Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2016-04-01' AND NEW.create_dt < DATE '2016-07-01') THEN - INSERT INTO games_2016Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2016-07-01' AND NEW.create_dt < DATE '2016-10-01') THEN - INSERT INTO games_2016Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2016-10-01' AND NEW.create_dt < DATE '2017-01-01') THEN - INSERT INTO games_2016Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2017-01-01' AND NEW.create_dt < DATE '2017-04-01') THEN - INSERT INTO games_2017Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2017-04-01' AND NEW.create_dt < DATE '2017-07-01') THEN - INSERT INTO games_2017Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2017-07-01' AND NEW.create_dt < DATE '2017-10-01') THEN - INSERT INTO games_2017Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2017-10-01' AND NEW.create_dt < DATE '2018-01-01') THEN - INSERT INTO games_2017Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2018-01-01' AND NEW.create_dt < DATE '2018-04-01') THEN - INSERT INTO games_2018Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2018-04-01' AND NEW.create_dt < DATE '2018-07-01') THEN - INSERT INTO games_2018Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2018-07-01' AND NEW.create_dt < DATE '2018-10-01') THEN - INSERT INTO games_2018Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2018-10-01' AND NEW.create_dt < DATE '2019-01-01') THEN - INSERT INTO games_2018Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2019-01-01' AND NEW.create_dt < DATE '2019-04-01') THEN - INSERT INTO games_2019Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2019-04-01' AND NEW.create_dt < DATE '2019-07-01') THEN - INSERT INTO games_2019Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2019-07-01' AND NEW.create_dt < DATE '2019-10-01') THEN - INSERT INTO games_2019Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2019-10-01' AND NEW.create_dt < DATE '2020-01-01') THEN - INSERT INTO games_2019Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2020-01-01' AND NEW.create_dt < DATE '2020-04-01') THEN + IF (NEW.create_dt >= DATE '2020-01-01' AND NEW.create_dt < DATE '2020-04-01') THEN INSERT INTO games_2020Q1 VALUES (NEW.*); ELSIF (NEW.create_dt >= DATE '2020-04-01' AND NEW.create_dt < DATE '2020-07-01') THEN INSERT INTO games_2020Q2 VALUES (NEW.*); @@ -57,6 +9,46 @@ BEGIN INSERT INTO games_2020Q3 VALUES (NEW.*); ELSIF (NEW.create_dt >= DATE '2020-10-01' AND NEW.create_dt < DATE '2021-01-01') THEN INSERT INTO games_2020Q4 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2021-01-01' AND NEW.create_dt < DATE '2021-04-01') THEN + INSERT INTO games_2021Q1 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2021-04-01' AND NEW.create_dt < DATE '2021-07-01') THEN + INSERT INTO games_2021Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2021-07-01' AND NEW.create_dt < DATE '2021-10-01') THEN + INSERT INTO games_2021Q3 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2021-10-01' AND NEW.create_dt < DATE '2022-01-01') THEN + INSERT INTO games_2021Q4 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2022-01-01' AND NEW.create_dt < DATE '2022-04-01') THEN + INSERT INTO games_2022Q1 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2022-04-01' AND NEW.create_dt < DATE '2022-07-01') THEN + INSERT INTO games_2022Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2022-07-01' AND NEW.create_dt < DATE '2022-10-01') THEN + INSERT INTO games_2022Q3 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2022-10-01' AND NEW.create_dt < DATE '2023-01-01') THEN + INSERT INTO games_2022Q4 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2023-01-01' AND NEW.create_dt < DATE '2023-04-01') THEN + INSERT INTO games_2023Q1 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2023-04-01' AND NEW.create_dt < DATE '2023-07-01') THEN + INSERT INTO games_2023Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2023-07-01' AND NEW.create_dt < DATE '2023-10-01') THEN + INSERT INTO games_2023Q3 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2023-10-01' AND NEW.create_dt < DATE '2024-01-01') THEN + INSERT INTO games_2023Q4 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2024-01-01' AND NEW.create_dt < DATE '2024-04-01') THEN + INSERT INTO games_2024Q1 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2024-04-01' AND NEW.create_dt < DATE '2024-07-01') THEN + INSERT INTO games_2024Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2024-07-01' AND NEW.create_dt < DATE '2024-10-01') THEN + INSERT INTO games_2024Q3 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2024-10-01' AND NEW.create_dt < DATE '2025-01-01') THEN + INSERT INTO games_2024Q4 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2025-01-01' AND NEW.create_dt < DATE '2025-04-01') THEN + INSERT INTO games_2025Q1 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2025-04-01' AND NEW.create_dt < DATE '2025-07-01') THEN + INSERT INTO games_2025Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2025-07-01' AND NEW.create_dt < DATE '2025-10-01') THEN + INSERT INTO games_2025Q3 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2025-10-01' AND NEW.create_dt < DATE '2026-01-01') THEN + INSERT INTO games_2025Q4 VALUES (NEW.*); ELSE RAISE EXCEPTION 'Date out of range. Fix the games_ins() trigger!'; END IF; @@ -65,6 +57,7 @@ END $$ LANGUAGE plpgsql; + DROP TRIGGER IF EXISTS games_ins_trg ON xonstat.games; CREATE TRIGGER games_ins_trg BEFORE INSERT on xonstat.games diff --git a/triggers/player_game_frag_matrix_ins_trg.sql b/triggers/player_game_frag_matrix_ins_trg.sql index 1b9f117..8290f15 100644 --- a/triggers/player_game_frag_matrix_ins_trg.sql +++ b/triggers/player_game_frag_matrix_ins_trg.sql @@ -1,25 +1,7 @@ CREATE OR REPLACE FUNCTION player_game_frag_matrix_ins() RETURNS TRIGGER AS $$ BEGIN - IF (NEW.create_dt >= DATE '2017-10-01' AND NEW.create_dt < DATE '2018-01-01') THEN - INSERT INTO player_game_frag_matrix_2017Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2018-01-01' AND NEW.create_dt < DATE '2018-04-01') THEN - INSERT INTO player_game_frag_matrix_2018Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2018-04-01' AND NEW.create_dt < DATE '2018-07-01') THEN - INSERT INTO player_game_frag_matrix_2018Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2018-07-01' AND NEW.create_dt < DATE '2018-10-01') THEN - INSERT INTO player_game_frag_matrix_2018Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2018-10-01' AND NEW.create_dt < DATE '2019-01-01') THEN - INSERT INTO player_game_frag_matrix_2018Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2019-01-01' AND NEW.create_dt < DATE '2019-04-01') THEN - INSERT INTO player_game_frag_matrix_2019Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2019-04-01' AND NEW.create_dt < DATE '2019-07-01') THEN - INSERT INTO player_game_frag_matrix_2019Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2019-07-01' AND NEW.create_dt < DATE '2019-10-01') THEN - INSERT INTO player_game_frag_matrix_2019Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2019-10-01' AND NEW.create_dt < DATE '2020-01-01') THEN - INSERT INTO player_game_frag_matrix_2019Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2020-01-01' AND NEW.create_dt < DATE '2020-04-01') THEN + IF (NEW.create_dt >= DATE '2020-01-01' AND NEW.create_dt < DATE '2020-04-01') THEN INSERT INTO player_game_frag_matrix_2020Q1 VALUES (NEW.*); ELSIF (NEW.create_dt >= DATE '2020-04-01' AND NEW.create_dt < DATE '2020-07-01') THEN INSERT INTO player_game_frag_matrix_2020Q2 VALUES (NEW.*); @@ -27,6 +9,46 @@ BEGIN INSERT INTO player_game_frag_matrix_2020Q3 VALUES (NEW.*); ELSIF (NEW.create_dt >= DATE '2020-10-01' AND NEW.create_dt < DATE '2021-01-01') THEN INSERT INTO player_game_frag_matrix_2020Q4 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2021-01-01' AND NEW.create_dt < DATE '2021-04-01') THEN + INSERT INTO player_game_frag_matrix_2021Q1 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2021-04-01' AND NEW.create_dt < DATE '2021-07-01') THEN + INSERT INTO player_game_frag_matrix_2021Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2021-07-01' AND NEW.create_dt < DATE '2021-10-01') THEN + INSERT INTO player_game_frag_matrix_2021Q3 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2021-10-01' AND NEW.create_dt < DATE '2022-01-01') THEN + INSERT INTO player_game_frag_matrix_2021Q4 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2022-01-01' AND NEW.create_dt < DATE '2022-04-01') THEN + INSERT INTO player_game_frag_matrix_2022Q1 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2022-04-01' AND NEW.create_dt < DATE '2022-07-01') THEN + INSERT INTO player_game_frag_matrix_2022Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2022-07-01' AND NEW.create_dt < DATE '2022-10-01') THEN + INSERT INTO player_game_frag_matrix_2022Q3 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2022-10-01' AND NEW.create_dt < DATE '2023-01-01') THEN + INSERT INTO player_game_frag_matrix_2022Q4 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2023-01-01' AND NEW.create_dt < DATE '2023-04-01') THEN + INSERT INTO player_game_frag_matrix_2023Q1 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2023-04-01' AND NEW.create_dt < DATE '2023-07-01') THEN + INSERT INTO player_game_frag_matrix_2023Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2023-07-01' AND NEW.create_dt < DATE '2023-10-01') THEN + INSERT INTO player_game_frag_matrix_2023Q3 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2023-10-01' AND NEW.create_dt < DATE '2024-01-01') THEN + INSERT INTO player_game_frag_matrix_2023Q4 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2024-01-01' AND NEW.create_dt < DATE '2024-04-01') THEN + INSERT INTO player_game_frag_matrix_2024Q1 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2024-04-01' AND NEW.create_dt < DATE '2024-07-01') THEN + INSERT INTO player_game_frag_matrix_2024Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2024-07-01' AND NEW.create_dt < DATE '2024-10-01') THEN + INSERT INTO player_game_frag_matrix_2024Q3 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2024-10-01' AND NEW.create_dt < DATE '2025-01-01') THEN + INSERT INTO player_game_frag_matrix_2024Q4 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2025-01-01' AND NEW.create_dt < DATE '2025-04-01') THEN + INSERT INTO player_game_frag_matrix_2025Q1 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2025-04-01' AND NEW.create_dt < DATE '2025-07-01') THEN + INSERT INTO player_game_frag_matrix_2025Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2025-07-01' AND NEW.create_dt < DATE '2025-10-01') THEN + INSERT INTO player_game_frag_matrix_2025Q3 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2025-10-01' AND NEW.create_dt < DATE '2026-01-01') THEN + INSERT INTO player_game_frag_matrix_2025Q4 VALUES (NEW.*); ELSE RAISE EXCEPTION 'Date out of range. Fix the player_game_frag_matrix_ins() trigger!'; END IF; diff --git a/triggers/player_game_stats_ins_trg.sql b/triggers/player_game_stats_ins_trg.sql index 28a808d..66fcc1c 100644 --- a/triggers/player_game_stats_ins_trg.sql +++ b/triggers/player_game_stats_ins_trg.sql @@ -1,55 +1,7 @@ CREATE OR REPLACE FUNCTION player_game_stats_ins() RETURNS TRIGGER AS $$ BEGIN - IF (NEW.create_dt >= DATE '2014-01-01' AND NEW.create_dt < DATE '2014-04-01') THEN - INSERT INTO player_game_stats_2014Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2014-04-01' AND NEW.create_dt < DATE '2014-07-01') THEN - INSERT INTO player_game_stats_2014Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2014-07-01' AND NEW.create_dt < DATE '2014-10-01') THEN - INSERT INTO player_game_stats_2014Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2014-10-01' AND NEW.create_dt < DATE '2015-01-01') THEN - INSERT INTO player_game_stats_2014Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2015-01-01' AND NEW.create_dt < DATE '2015-04-01') THEN - INSERT INTO player_game_stats_2015Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2015-04-01' AND NEW.create_dt < DATE '2015-07-01') THEN - INSERT INTO player_game_stats_2015Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2015-07-01' AND NEW.create_dt < DATE '2015-10-01') THEN - INSERT INTO player_game_stats_2015Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2015-10-01' AND NEW.create_dt < DATE '2016-01-01') THEN - INSERT INTO player_game_stats_2015Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2016-01-01' AND NEW.create_dt < DATE '2016-04-01') THEN - INSERT INTO player_game_stats_2016Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2016-04-01' AND NEW.create_dt < DATE '2016-07-01') THEN - INSERT INTO player_game_stats_2016Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2016-07-01' AND NEW.create_dt < DATE '2016-10-01') THEN - INSERT INTO player_game_stats_2016Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2016-10-01' AND NEW.create_dt < DATE '2017-01-01') THEN - INSERT INTO player_game_stats_2016Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2017-01-01' AND NEW.create_dt < DATE '2017-04-01') THEN - INSERT INTO player_game_stats_2017Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2017-04-01' AND NEW.create_dt < DATE '2017-07-01') THEN - INSERT INTO player_game_stats_2017Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2017-07-01' AND NEW.create_dt < DATE '2017-10-01') THEN - INSERT INTO player_game_stats_2017Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2017-10-01' AND NEW.create_dt < DATE '2018-01-01') THEN - INSERT INTO player_game_stats_2017Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2018-01-01' AND NEW.create_dt < DATE '2018-04-01') THEN - INSERT INTO player_game_stats_2018Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2018-04-01' AND NEW.create_dt < DATE '2018-07-01') THEN - INSERT INTO player_game_stats_2018Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2018-07-01' AND NEW.create_dt < DATE '2018-10-01') THEN - INSERT INTO player_game_stats_2018Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2018-10-01' AND NEW.create_dt < DATE '2019-01-01') THEN - INSERT INTO player_game_stats_2018Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2019-01-01' AND NEW.create_dt < DATE '2019-04-01') THEN - INSERT INTO player_game_stats_2019Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2019-04-01' AND NEW.create_dt < DATE '2019-07-01') THEN - INSERT INTO player_game_stats_2019Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2019-07-01' AND NEW.create_dt < DATE '2019-10-01') THEN - INSERT INTO player_game_stats_2019Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2019-10-01' AND NEW.create_dt < DATE '2020-01-01') THEN - INSERT INTO player_game_stats_2019Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2020-01-01' AND NEW.create_dt < DATE '2020-04-01') THEN + IF (NEW.create_dt >= DATE '2020-01-01' AND NEW.create_dt < DATE '2020-04-01') THEN INSERT INTO player_game_stats_2020Q1 VALUES (NEW.*); ELSIF (NEW.create_dt >= DATE '2020-04-01' AND NEW.create_dt < DATE '2020-07-01') THEN INSERT INTO player_game_stats_2020Q2 VALUES (NEW.*); @@ -57,6 +9,46 @@ BEGIN INSERT INTO player_game_stats_2020Q3 VALUES (NEW.*); ELSIF (NEW.create_dt >= DATE '2020-10-01' AND NEW.create_dt < DATE '2021-01-01') THEN INSERT INTO player_game_stats_2020Q4 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2021-01-01' AND NEW.create_dt < DATE '2021-04-01') THEN + INSERT INTO player_game_stats_2021Q1 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2021-04-01' AND NEW.create_dt < DATE '2021-07-01') THEN + INSERT INTO player_game_stats_2021Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2021-07-01' AND NEW.create_dt < DATE '2021-10-01') THEN + INSERT INTO player_game_stats_2021Q3 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2021-10-01' AND NEW.create_dt < DATE '2022-01-01') THEN + INSERT INTO player_game_stats_2021Q4 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2022-01-01' AND NEW.create_dt < DATE '2022-04-01') THEN + INSERT INTO player_game_stats_2022Q1 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2022-04-01' AND NEW.create_dt < DATE '2022-07-01') THEN + INSERT INTO player_game_stats_2022Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2022-07-01' AND NEW.create_dt < DATE '2022-10-01') THEN + INSERT INTO player_game_stats_2022Q3 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2022-10-01' AND NEW.create_dt < DATE '2023-01-01') THEN + INSERT INTO player_game_stats_2022Q4 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2023-01-01' AND NEW.create_dt < DATE '2023-04-01') THEN + INSERT INTO player_game_stats_2023Q1 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2023-04-01' AND NEW.create_dt < DATE '2023-07-01') THEN + INSERT INTO player_game_stats_2023Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2023-07-01' AND NEW.create_dt < DATE '2023-10-01') THEN + INSERT INTO player_game_stats_2023Q3 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2023-10-01' AND NEW.create_dt < DATE '2024-01-01') THEN + INSERT INTO player_game_stats_2023Q4 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2024-01-01' AND NEW.create_dt < DATE '2024-04-01') THEN + INSERT INTO player_game_stats_2024Q1 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2024-04-01' AND NEW.create_dt < DATE '2024-07-01') THEN + INSERT INTO player_game_stats_2024Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2024-07-01' AND NEW.create_dt < DATE '2024-10-01') THEN + INSERT INTO player_game_stats_2024Q3 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2024-10-01' AND NEW.create_dt < DATE '2025-01-01') THEN + INSERT INTO player_game_stats_2024Q4 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2025-01-01' AND NEW.create_dt < DATE '2025-04-01') THEN + INSERT INTO player_game_stats_2025Q1 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2025-04-01' AND NEW.create_dt < DATE '2025-07-01') THEN + INSERT INTO player_game_stats_2025Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2025-07-01' AND NEW.create_dt < DATE '2025-10-01') THEN + INSERT INTO player_game_stats_2025Q3 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2025-10-01' AND NEW.create_dt < DATE '2026-01-01') THEN + INSERT INTO player_game_stats_2025Q4 VALUES (NEW.*); ELSE RAISE EXCEPTION 'Date out of range. Fix the player_game_stats_ins() trigger!'; END IF; diff --git a/triggers/player_weapon_stats_ins_trg.sql b/triggers/player_weapon_stats_ins_trg.sql index e0c256e..f109622 100644 --- a/triggers/player_weapon_stats_ins_trg.sql +++ b/triggers/player_weapon_stats_ins_trg.sql @@ -1,55 +1,7 @@ CREATE OR REPLACE FUNCTION player_weapon_stats_ins() RETURNS TRIGGER AS $$ BEGIN - IF (NEW.create_dt >= DATE '2014-01-01' AND NEW.create_dt < DATE '2014-04-01') THEN - INSERT INTO player_weapon_stats_2014Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2014-04-01' AND NEW.create_dt < DATE '2014-07-01') THEN - INSERT INTO player_weapon_stats_2014Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2014-07-01' AND NEW.create_dt < DATE '2014-10-01') THEN - INSERT INTO player_weapon_stats_2014Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2014-10-01' AND NEW.create_dt < DATE '2015-01-01') THEN - INSERT INTO player_weapon_stats_2014Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2015-01-01' AND NEW.create_dt < DATE '2015-04-01') THEN - INSERT INTO player_weapon_stats_2015Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2015-04-01' AND NEW.create_dt < DATE '2015-07-01') THEN - INSERT INTO player_weapon_stats_2015Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2015-07-01' AND NEW.create_dt < DATE '2015-10-01') THEN - INSERT INTO player_weapon_stats_2015Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2015-10-01' AND NEW.create_dt < DATE '2016-01-01') THEN - INSERT INTO player_weapon_stats_2015Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2016-01-01' AND NEW.create_dt < DATE '2016-04-01') THEN - INSERT INTO player_weapon_stats_2016Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2016-04-01' AND NEW.create_dt < DATE '2016-07-01') THEN - INSERT INTO player_weapon_stats_2016Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2016-07-01' AND NEW.create_dt < DATE '2016-10-01') THEN - INSERT INTO player_weapon_stats_2016Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2016-10-01' AND NEW.create_dt < DATE '2017-01-01') THEN - INSERT INTO player_weapon_stats_2016Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2017-01-01' AND NEW.create_dt < DATE '2017-04-01') THEN - INSERT INTO player_weapon_stats_2017Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2017-04-01' AND NEW.create_dt < DATE '2017-07-01') THEN - INSERT INTO player_weapon_stats_2017Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2017-07-01' AND NEW.create_dt < DATE '2017-10-01') THEN - INSERT INTO player_weapon_stats_2017Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2017-10-01' AND NEW.create_dt < DATE '2018-01-01') THEN - INSERT INTO player_weapon_stats_2017Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2018-01-01' AND NEW.create_dt < DATE '2018-04-01') THEN - INSERT INTO player_weapon_stats_2018Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2018-04-01' AND NEW.create_dt < DATE '2018-07-01') THEN - INSERT INTO player_weapon_stats_2018Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2018-07-01' AND NEW.create_dt < DATE '2018-10-01') THEN - INSERT INTO player_weapon_stats_2018Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2018-10-01' AND NEW.create_dt < DATE '2019-01-01') THEN - INSERT INTO player_weapon_stats_2018Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2019-01-01' AND NEW.create_dt < DATE '2019-04-01') THEN - INSERT INTO player_weapon_stats_2019Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2019-04-01' AND NEW.create_dt < DATE '2019-07-01') THEN - INSERT INTO player_weapon_stats_2019Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2019-07-01' AND NEW.create_dt < DATE '2019-10-01') THEN - INSERT INTO player_weapon_stats_2019Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2019-10-01' AND NEW.create_dt < DATE '2020-01-01') THEN - INSERT INTO player_weapon_stats_2019Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2020-01-01' AND NEW.create_dt < DATE '2020-04-01') THEN + IF (NEW.create_dt >= DATE '2020-01-01' AND NEW.create_dt < DATE '2020-04-01') THEN INSERT INTO player_weapon_stats_2020Q1 VALUES (NEW.*); ELSIF (NEW.create_dt >= DATE '2020-04-01' AND NEW.create_dt < DATE '2020-07-01') THEN INSERT INTO player_weapon_stats_2020Q2 VALUES (NEW.*); @@ -57,6 +9,46 @@ BEGIN INSERT INTO player_weapon_stats_2020Q3 VALUES (NEW.*); ELSIF (NEW.create_dt >= DATE '2020-10-01' AND NEW.create_dt < DATE '2021-01-01') THEN INSERT INTO player_weapon_stats_2020Q4 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2021-01-01' AND NEW.create_dt < DATE '2021-04-01') THEN + INSERT INTO player_weapon_stats_2021Q1 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2021-04-01' AND NEW.create_dt < DATE '2021-07-01') THEN + INSERT INTO player_weapon_stats_2021Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2021-07-01' AND NEW.create_dt < DATE '2021-10-01') THEN + INSERT INTO player_weapon_stats_2021Q3 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2021-10-01' AND NEW.create_dt < DATE '2022-01-01') THEN + INSERT INTO player_weapon_stats_2021Q4 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2022-01-01' AND NEW.create_dt < DATE '2022-04-01') THEN + INSERT INTO player_weapon_stats_2022Q1 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2022-04-01' AND NEW.create_dt < DATE '2022-07-01') THEN + INSERT INTO player_weapon_stats_2022Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2022-07-01' AND NEW.create_dt < DATE '2022-10-01') THEN + INSERT INTO player_weapon_stats_2022Q3 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2022-10-01' AND NEW.create_dt < DATE '2023-01-01') THEN + INSERT INTO player_weapon_stats_2022Q4 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2023-01-01' AND NEW.create_dt < DATE '2023-04-01') THEN + INSERT INTO player_weapon_stats_2023Q1 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2023-04-01' AND NEW.create_dt < DATE '2023-07-01') THEN + INSERT INTO player_weapon_stats_2023Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2023-07-01' AND NEW.create_dt < DATE '2023-10-01') THEN + INSERT INTO player_weapon_stats_2023Q3 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2023-10-01' AND NEW.create_dt < DATE '2024-01-01') THEN + INSERT INTO player_weapon_stats_2023Q4 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2024-01-01' AND NEW.create_dt < DATE '2024-04-01') THEN + INSERT INTO player_weapon_stats_2024Q1 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2024-04-01' AND NEW.create_dt < DATE '2024-07-01') THEN + INSERT INTO player_weapon_stats_2024Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2024-07-01' AND NEW.create_dt < DATE '2024-10-01') THEN + INSERT INTO player_weapon_stats_2024Q3 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2024-10-01' AND NEW.create_dt < DATE '2025-01-01') THEN + INSERT INTO player_weapon_stats_2024Q4 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2025-01-01' AND NEW.create_dt < DATE '2025-04-01') THEN + INSERT INTO player_weapon_stats_2025Q1 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2025-04-01' AND NEW.create_dt < DATE '2025-07-01') THEN + INSERT INTO player_weapon_stats_2025Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2025-07-01' AND NEW.create_dt < DATE '2025-10-01') THEN + INSERT INTO player_weapon_stats_2025Q3 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2025-10-01' AND NEW.create_dt < DATE '2026-01-01') THEN + INSERT INTO player_weapon_stats_2025Q4 VALUES (NEW.*); ELSE RAISE EXCEPTION 'Date out of range. Fix the player_weapon_stats_ins() trigger!'; END IF; diff --git a/triggers/team_game_stats_ins_trg.sql b/triggers/team_game_stats_ins_trg.sql index 0649a39..86ef3a4 100644 --- a/triggers/team_game_stats_ins_trg.sql +++ b/triggers/team_game_stats_ins_trg.sql @@ -1,55 +1,7 @@ CREATE OR REPLACE FUNCTION team_game_stats_ins() RETURNS TRIGGER AS $$ BEGIN - IF (NEW.create_dt >= DATE '2014-01-01' AND NEW.create_dt < DATE '2014-04-01') THEN - INSERT INTO team_game_stats_2014Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2014-04-01' AND NEW.create_dt < DATE '2014-07-01') THEN - INSERT INTO team_game_stats_2014Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2014-07-01' AND NEW.create_dt < DATE '2014-10-01') THEN - INSERT INTO team_game_stats_2014Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2014-10-01' AND NEW.create_dt < DATE '2015-01-01') THEN - INSERT INTO team_game_stats_2014Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2015-01-01' AND NEW.create_dt < DATE '2015-04-01') THEN - INSERT INTO team_game_stats_2015Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2015-04-01' AND NEW.create_dt < DATE '2015-07-01') THEN - INSERT INTO team_game_stats_2015Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2015-07-01' AND NEW.create_dt < DATE '2015-10-01') THEN - INSERT INTO team_game_stats_2015Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2015-10-01' AND NEW.create_dt < DATE '2016-01-01') THEN - INSERT INTO team_game_stats_2015Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2016-01-01' AND NEW.create_dt < DATE '2016-04-01') THEN - INSERT INTO team_game_stats_2016Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2016-04-01' AND NEW.create_dt < DATE '2016-07-01') THEN - INSERT INTO team_game_stats_2016Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2016-07-01' AND NEW.create_dt < DATE '2016-10-01') THEN - INSERT INTO team_game_stats_2016Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2016-10-01' AND NEW.create_dt < DATE '2017-01-01') THEN - INSERT INTO team_game_stats_2016Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2017-01-01' AND NEW.create_dt < DATE '2017-04-01') THEN - INSERT INTO team_game_stats_2017Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2017-04-01' AND NEW.create_dt < DATE '2017-07-01') THEN - INSERT INTO team_game_stats_2017Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2017-07-01' AND NEW.create_dt < DATE '2017-10-01') THEN - INSERT INTO team_game_stats_2017Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2017-10-01' AND NEW.create_dt < DATE '2018-01-01') THEN - INSERT INTO team_game_stats_2017Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2018-01-01' AND NEW.create_dt < DATE '2018-04-01') THEN - INSERT INTO team_game_stats_2018Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2018-04-01' AND NEW.create_dt < DATE '2018-07-01') THEN - INSERT INTO team_game_stats_2018Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2018-07-01' AND NEW.create_dt < DATE '2018-10-01') THEN - INSERT INTO team_game_stats_2018Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2018-10-01' AND NEW.create_dt < DATE '2019-01-01') THEN - INSERT INTO team_game_stats_2018Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2019-01-01' AND NEW.create_dt < DATE '2019-04-01') THEN - INSERT INTO team_game_stats_2019Q1 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2019-04-01' AND NEW.create_dt < DATE '2019-07-01') THEN - INSERT INTO team_game_stats_2019Q2 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2019-07-01' AND NEW.create_dt < DATE '2019-10-01') THEN - INSERT INTO team_game_stats_2019Q3 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2019-10-01' AND NEW.create_dt < DATE '2020-01-01') THEN - INSERT INTO team_game_stats_2019Q4 VALUES (NEW.*); - ELSIF (NEW.create_dt >= DATE '2020-01-01' AND NEW.create_dt < DATE '2020-04-01') THEN + IF (NEW.create_dt >= DATE '2020-01-01' AND NEW.create_dt < DATE '2020-04-01') THEN INSERT INTO team_game_stats_2020Q1 VALUES (NEW.*); ELSIF (NEW.create_dt >= DATE '2020-04-01' AND NEW.create_dt < DATE '2020-07-01') THEN INSERT INTO team_game_stats_2020Q2 VALUES (NEW.*); @@ -57,6 +9,46 @@ BEGIN INSERT INTO team_game_stats_2020Q3 VALUES (NEW.*); ELSIF (NEW.create_dt >= DATE '2020-10-01' AND NEW.create_dt < DATE '2021-01-01') THEN INSERT INTO team_game_stats_2020Q4 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2021-01-01' AND NEW.create_dt < DATE '2021-04-01') THEN + INSERT INTO team_game_stats_2021Q1 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2021-04-01' AND NEW.create_dt < DATE '2021-07-01') THEN + INSERT INTO team_game_stats_2021Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2021-07-01' AND NEW.create_dt < DATE '2021-10-01') THEN + INSERT INTO team_game_stats_2021Q3 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2021-10-01' AND NEW.create_dt < DATE '2022-01-01') THEN + INSERT INTO team_game_stats_2021Q4 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2022-01-01' AND NEW.create_dt < DATE '2022-04-01') THEN + INSERT INTO team_game_stats_2022Q1 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2022-04-01' AND NEW.create_dt < DATE '2022-07-01') THEN + INSERT INTO team_game_stats_2022Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2022-07-01' AND NEW.create_dt < DATE '2022-10-01') THEN + INSERT INTO team_game_stats_2022Q3 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2022-10-01' AND NEW.create_dt < DATE '2023-01-01') THEN + INSERT INTO team_game_stats_2022Q4 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2023-01-01' AND NEW.create_dt < DATE '2023-04-01') THEN + INSERT INTO team_game_stats_2023Q1 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2023-04-01' AND NEW.create_dt < DATE '2023-07-01') THEN + INSERT INTO team_game_stats_2023Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2023-07-01' AND NEW.create_dt < DATE '2023-10-01') THEN + INSERT INTO team_game_stats_2023Q3 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2023-10-01' AND NEW.create_dt < DATE '2024-01-01') THEN + INSERT INTO team_game_stats_2023Q4 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2024-01-01' AND NEW.create_dt < DATE '2024-04-01') THEN + INSERT INTO team_game_stats_2024Q1 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2024-04-01' AND NEW.create_dt < DATE '2024-07-01') THEN + INSERT INTO team_game_stats_2024Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2024-07-01' AND NEW.create_dt < DATE '2024-10-01') THEN + INSERT INTO team_game_stats_2024Q3 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2024-10-01' AND NEW.create_dt < DATE '2025-01-01') THEN + INSERT INTO team_game_stats_2024Q4 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2025-01-01' AND NEW.create_dt < DATE '2025-04-01') THEN + INSERT INTO team_game_stats_2025Q1 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2025-04-01' AND NEW.create_dt < DATE '2025-07-01') THEN + INSERT INTO team_game_stats_2025Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2025-07-01' AND NEW.create_dt < DATE '2025-10-01') THEN + INSERT INTO team_game_stats_2025Q3 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2025-10-01' AND NEW.create_dt < DATE '2026-01-01') THEN + INSERT INTO team_game_stats_2025Q4 VALUES (NEW.*); ELSE RAISE EXCEPTION 'Date out of range. Fix the team_game_stats_ins() trigger!'; END IF; -- 2.39.2