From 3681f6908542ccb6dde1487c559b775fb8627686 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 2 Jan 2014 11:08:23 +1100 Subject: [PATCH] BUGFIX: if users somehow deleted the uncategorized category, it is re-created --- db/fixtures/001_categories.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/fixtures/001_categories.rb b/db/fixtures/001_categories.rb index 1c1558cdb56..7d5770253df 100644 --- a/db/fixtures/001_categories.rb +++ b/db/fixtures/001_categories.rb @@ -1,5 +1,5 @@ SiteSetting.refresh! -if SiteSetting.uncategorized_category_id == -1 +if SiteSetting.uncategorized_category_id == -1 || !Category.exists?(SiteSetting.uncategorized_category_id) puts "Seeding uncategorized category!" result = Category.exec_sql "SELECT 1 FROM categories WHERE name = 'uncategorized'" @@ -15,6 +15,7 @@ if SiteSetting.uncategorized_category_id == -1 " category_id = result[0]["id"].to_i + Category.exec_sql "DELETE FROM site_settings where name = 'uncategorized_category_id'" 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