2014-05-12 11:31:33 +08:00
|
|
|
# fix any bust caches post initial migration
|
|
|
|
ActiveRecord::Base.send(:subclasses).each{|m| p m; m.reset_column_information}
|
|
|
|
|
2013-10-25 07:31:33 +08:00
|
|
|
SiteSetting.refresh!
|
2014-01-02 08:08:23 +08:00
|
|
|
if SiteSetting.uncategorized_category_id == -1 || !Category.exists?(SiteSetting.uncategorized_category_id)
|
2013-10-25 07:31:33 +08:00
|
|
|
puts "Seeding uncategorized category!"
|
|
|
|
|
|
|
|
result = Category.exec_sql "SELECT 1 FROM categories WHERE name = 'uncategorized'"
|
|
|
|
name = 'uncategorized'
|
|
|
|
if result.count > 0
|
|
|
|
name << SecureRandom.hex
|
|
|
|
end
|
|
|
|
|
|
|
|
result = Category.exec_sql "INSERT INTO categories
|
|
|
|
(name,color,slug,description,text_color, user_id, created_at, updated_at, position)
|
|
|
|
VALUES ('#{name}', 'AB9364', 'uncategorized', '', 'FFFFFF', -1, now(), now(), 1 )
|
|
|
|
RETURNING id
|
|
|
|
"
|
|
|
|
category_id = result[0]["id"].to_i
|
|
|
|
|
2014-01-02 08:08:23 +08:00
|
|
|
Category.exec_sql "DELETE FROM site_settings where name = 'uncategorized_category_id'"
|
2013-10-25 07:31:33 +08:00
|
|
|
Category.exec_sql "INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
|
|
|
|
VALUES ('uncategorized_category_id', 3, #{category_id}, now(), now())"
|
|
|
|
end
|