mirror of
https://github.com/discourse/discourse.git
synced 2024-12-19 16:35:57 +08:00
25138db433
This commit promotes all post_deploy migrations which existed in Discourse v3.0.0 (timestamp <= 20221212234948)
26 lines
675 B
Ruby
26 lines
675 B
Ruby
# frozen_string_literal: true
|
|
|
|
class DropUserStatCountConstraints < ActiveRecord::Migration[6.1]
|
|
def up
|
|
execute "ALTER TABLE user_stats DROP CONSTRAINT topic_count_positive"
|
|
execute "ALTER TABLE user_stats DROP CONSTRAINT post_count_positive"
|
|
end
|
|
|
|
def down
|
|
execute(<<~SQL)
|
|
UPDATE user_stats
|
|
SET post_count = 0
|
|
WHERE post_count < 0
|
|
SQL
|
|
|
|
execute(<<~SQL)
|
|
UPDATE user_stats
|
|
SET topic_count = 0
|
|
WHERE topic_count < 0
|
|
SQL
|
|
|
|
execute "ALTER TABLE user_stats ADD CONSTRAINT topic_count_positive CHECK (topic_count >= 0)"
|
|
execute "ALTER TABLE user_stats ADD CONSTRAINT post_count_positive CHECK (post_count >= 0)"
|
|
end
|
|
end
|