diff --git a/src/main/resources/db/migration/V2__create_user_monthly_stat_table.sql b/src/main/resources/db/migration/V2__create_user_monthly_stat_table.sql new file mode 100644 index 0000000..fac2923 --- /dev/null +++ b/src/main/resources/db/migration/V2__create_user_monthly_stat_table.sql @@ -0,0 +1,10 @@ +CREATE TABLE user_monthly_stat ( + id BIGSERIAL PRIMARY KEY, + user_id BIGINT NOT NULL, + year INT NOT NULL, + month INT NOT NULL, + record_count INT NOT NULL DEFAULT 0, + CONSTRAINT uq_user_monthly_stat UNIQUE (user_id, year, month), + CONSTRAINT fk_user_monthly_stat_user FOREIGN KEY (user_id) + REFERENCES users(id) +); diff --git a/src/main/resources/db/migration/V2__backfill_user_monthly_stat_from_existing_records.sql b/src/main/resources/db/migration/V3__backfill_user_monthly_stat_from_existing_records.sql similarity index 100% rename from src/main/resources/db/migration/V2__backfill_user_monthly_stat_from_existing_records.sql rename to src/main/resources/db/migration/V3__backfill_user_monthly_stat_from_existing_records.sql