mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
Migrate auto closed topics too
This commit is contained in:
parent
faf4f44776
commit
201617811e
3 changed files with 21 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
||||||
const icons = {
|
const icons = {
|
||||||
'closed.enabled': 'lock',
|
'closed.enabled': 'lock',
|
||||||
'closed.disabled': 'unlock-alt',
|
'closed.disabled': 'unlock-alt',
|
||||||
|
'autoclosed.enabled': 'lock',
|
||||||
|
'autoclosed.disabled': 'unlock-alt',
|
||||||
'archived.enabled': 'folder',
|
'archived.enabled': 'folder',
|
||||||
'archived.disabled': 'folder-open',
|
'archived.disabled': 'folder-open',
|
||||||
'pinned.enabled': 'thumb-tack',
|
'pinned.enabled': 'thumb-tack',
|
||||||
|
|
|
@ -120,6 +120,9 @@ en:
|
||||||
email: 'send this link in an email'
|
email: 'send this link in an email'
|
||||||
|
|
||||||
action_codes:
|
action_codes:
|
||||||
|
autoclosed:
|
||||||
|
enabled: 'closed this topic %{when}'
|
||||||
|
disabled: 'opened this topic %{when}'
|
||||||
closed:
|
closed:
|
||||||
enabled: 'closed this topic %{when}'
|
enabled: 'closed this topic %{when}'
|
||||||
disabled: 'opened this topic %{when}'
|
disabled: 'opened this topic %{when}'
|
||||||
|
|
16
db/migrate/20150729150523_migrate_auto_close_posts.rb
Normal file
16
db/migrate/20150729150523_migrate_auto_close_posts.rb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
class MigrateAutoClosePosts < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
strings = []
|
||||||
|
%w(days hours lastpost_days lastpost_hours lastpost_minutes).map do |k|
|
||||||
|
strings << I18n.t("topic_statuses.autoclosed_enabled_#{k}.one")
|
||||||
|
strings << I18n.t("topic_statuses.autoclosed_enabled_#{k}.other").sub("%{count}", "\\d+")
|
||||||
|
end
|
||||||
|
|
||||||
|
sql = "UPDATE posts SET action_code = 'autoclosed.enabled', post_type = 3 "
|
||||||
|
sql << "WHERE post_type = 2 AND ("
|
||||||
|
sql << strings.map {|s| "raw ~* #{ActiveRecord::Base.connection.quote(s)}" }.join(' OR ')
|
||||||
|
sql << ")"
|
||||||
|
|
||||||
|
execute sql
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue