FIX: migration would break if locale was forced to french

This commit is contained in:
Sam 2014-10-14 18:07:59 +11:00
parent 303b2a78cd
commit 2bace90054
1 changed files with 6 additions and 5 deletions

View File

@ -4,13 +4,14 @@ class AddMetaCategory < ActiveRecord::Migration
result = Category.exec_sql "SELECT 1 FROM site_settings where name = 'meta_category_id'"
if result.count == 0
description = I18n.t('meta_category_description')
name = I18n.t('meta_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}', '808281', 'FFFFFF', now(), now(), -1, '#{Slug.for(name)}', '#{description}', true, 1)
RETURNING id"
VALUES (:name, '808281', 'FFFFFF', now(), now(), -1, :slug, :description, true, 1)
RETURNING id", name: name, slug: Slug.for(name), description: description
category_id = result[0]["id"].to_i
execute "INSERT INTO site_settings(name, data_type, value, created_at, updated_at)