FIX: migrations broken in some non English various locales
This commit is contained in:
parent
9d113bd536
commit
cbe45975e8
|
@ -12,15 +12,19 @@ class AddLoungeCategory < ActiveRecord::Migration
|
|||
"CHANGE_ME"
|
||||
end
|
||||
|
||||
result = execute "INSERT INTO categories
|
||||
result = Category.exec_sql "INSERT INTO categories
|
||||
(name, color, text_color, created_at, updated_at, user_id, slug, description, read_restricted, position)
|
||||
VALUES ('#{name}', 'EEEEEE', '652D90', now(), now(), -1, '', '#{description}', true, 3)
|
||||
RETURNING id"
|
||||
VALUES (:name, 'EEEEEE', '652D90', now(), now(), -1, '', :description, true, 3)
|
||||
RETURNING id", name: name, description: description
|
||||
|
||||
category_id = result[0]["id"].to_i
|
||||
|
||||
execute "UPDATE categories SET slug='#{Slug.for(name, "#{category_id}-category")}' WHERE id=#{category_id}"
|
||||
Category.exec_sql "UPDATE categories SET slug = :slug
|
||||
WHERE id = :category_id",
|
||||
slug: Slug.for(name, "#{category_id}-category"), category_id: category_id
|
||||
|
||||
execute "INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
|
||||
VALUES ('lounge_category_id', 3, #{category_id}, now(), now())"
|
||||
VALUES ('lounge_category_id', 3, #{category_id.to_i}, now(), now())"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,7 +14,9 @@ class AddMetaCategory < ActiveRecord::Migration
|
|||
|
||||
category_id = result[0]["id"].to_i
|
||||
|
||||
execute "UPDATE categories SET slug='#{Slug.for(name, "#{category_id}-category")}' WHERE id=#{category_id}"
|
||||
Category.exec_sql "UPDATE categories SET slug=:slug WHERE id=:category_id",
|
||||
slug: Slug.for(name, "#{category_id}-category"), category_id: category_id
|
||||
|
||||
execute "INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
|
||||
VALUES ('meta_category_id', 3, #{category_id}, now(), now())"
|
||||
end
|
||||
|
|
|
@ -5,16 +5,21 @@ class AddStaffCategory < ActiveRecord::Migration
|
|||
if result.count == 0
|
||||
description = I18n.t('staff_category_description')
|
||||
name = I18n.t('staff_category_name')
|
||||
if Category.exec_sql("SELECT 1 FROM categories where name ilike '#{name}'").count == 0
|
||||
result = execute "INSERT INTO categories
|
||||
|
||||
if Category.exec_sql("SELECT 1 FROM categories where name ilike :name", name: name).count == 0
|
||||
|
||||
result = Category.exec_sql "INSERT INTO categories
|
||||
(name, color, text_color, created_at, updated_at, user_id, slug, description, read_restricted, position)
|
||||
VALUES ('#{name}', '283890', 'FFFFFF', now(), now(), -1, '', '#{description}', true, 2)
|
||||
RETURNING id"
|
||||
VALUES (:name, '283890', 'FFFFFF', now(), now(), -1, '', :description, true, 2)
|
||||
RETURNING id", name: name, description: description
|
||||
|
||||
category_id = result[0]["id"].to_i
|
||||
|
||||
execute "UPDATE categories SET slug='#{Slug.for(name, "#{category_id}-category")}' WHERE id=#{category_id}"
|
||||
Category.exec_sql "UPDATE categories SET slug=:slug WHERE id=:category_id",
|
||||
slug: Slug.for(name, "#{category_id}-category"), category_id: category_id
|
||||
|
||||
execute "INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
|
||||
VALUES ('staff_category_id', 3, #{category_id}, now(), now())"
|
||||
VALUES ('staff_category_id', 3, #{category_id.to_i}, now(), now())"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue