Files
dota-random-web/migrations/20260913170640_add_item_grades.up.sql
T
kwiialyssa edb4cd8613
CI/CD / Build (push) Successful in 5m59s
CI/CD / Frontend Build (push) Successful in 1m27s
CI/CD / Unit Tests (push) Failing after 1m12s
CI/CD / Docker (push) Skipped
CI/CD / Frontend Docker (push) Failing after 3m29s
feat(DRW-001) initial commit!
2026-09-13 20:37:48 +03:00

12 lines
503 B
SQL

ALTER TABLE items ADD COLUMN min_grade SMALLINT;
ALTER TABLE items ADD COLUMN max_grade SMALLINT;
-- Backfill any existing shop rows to grade 1-1 (a normal single-grade item)
-- before the constraint below starts requiring it.
UPDATE items SET min_grade = 1, max_grade = 1 WHERE source = 'shop';
ALTER TABLE items ADD CONSTRAINT grade_matches_source CHECK (
(source = 'shop' AND min_grade >= 1 AND max_grade >= min_grade)
OR (source = 'neutral' AND min_grade IS NULL AND max_grade IS NULL)
);