diff options
author | Petteri Räty <betelgeuse@gentoo.org> | 2011-03-12 19:50:20 +0200 |
---|---|---|
committer | Petteri Räty <betelgeuse@gentoo.org> | 2011-03-12 19:50:20 +0200 |
commit | 151c361a71c0b663c44c6bf5f7d310f1f12a87af (patch) | |
tree | 0cfd1511c28da5eb670f867f95b2508a2e361d20 /db | |
parent | Fix deprecation warnings from delayed_job (diff) | |
download | recruiting-webapp-151c361a71c0b663c44c6bf5f7d310f1f12a87af.tar.gz recruiting-webapp-151c361a71c0b663c44c6bf5f7d310f1f12a87af.tar.bz2 recruiting-webapp-151c361a71c0b663c44c6bf5f7d310f1f12a87af.zip |
Rename QuestionCategory to Category
We have a need for a many to many between questions and categories so
start the work by renaming QuestionCategory to just Category. This
allows us to add a pivot model with the name QuestionCategory.
Diffstat (limited to 'db')
-rw-r--r-- | db/fixtures/questions-email.yml | 2 | ||||
-rw-r--r-- | db/fixtures/questions-multichoice.yml | 2 | ||||
-rw-r--r-- | db/fixtures/questions.yml | 22 | ||||
-rw-r--r-- | db/migrate/20110312173240_rename_question_category_to_category.rb | 29 | ||||
-rw-r--r-- | db/schema.rb | 28 | ||||
-rw-r--r-- | db/seeds.rb | 16 |
6 files changed, 64 insertions, 35 deletions
diff --git a/db/fixtures/questions-email.yml b/db/fixtures/questions-email.yml index 6a4a64b..4d4c800 100644 --- a/db/fixtures/questions-email.yml +++ b/db/fixtures/questions-email.yml @@ -1,7 +1,7 @@ email_q1: title: Gentoo-dev-announce posting documentation: - question_category: ebuild + category: ebuild content: "Email a major eclass change announcement. Replace all @gentoo.org addresses with @localhost addresses. Remember to sign the email. The from field should match email you set in the application. diff --git a/db/fixtures/questions-multichoice.yml b/db/fixtures/questions-multichoice.yml index 58fe2b9..ae1af23 100644 --- a/db/fixtures/questions-multichoice.yml +++ b/db/fixtures/questions-multichoice.yml @@ -1,6 +1,6 @@ multichoice_q1: title: Fake multiple choice documentation: Fake - question_category: ebuild + category: ebuild content: Some question options: Option 1; Option 2; Option 3 diff --git a/db/fixtures/questions.yml b/db/fixtures/questions.yml index d0fc816..7ff29e1 100644 --- a/db/fixtures/questions.yml +++ b/db/fixtures/questions.yml @@ -1,7 +1,7 @@ ebuild_q1: title: Big changes in Gentoo documentation: GLEPs - question_category: ebuild + category: ebuild content: What is the proper method for suggesting a wide-ranging feature or enhancement to Gentoo? Describe the process for getting this feature approved and implemented. @@ -9,21 +9,21 @@ ebuild_q1: ebuild_q2: title: Responsibilities documentation: devrel policy - question_category: ebuild + category: ebuild content: Who should be contacted with complaints about specific developers or projects? ebuild_q3: title: Gentoo mailing lists documentation: gentoo.org - question_category: ebuild + category: ebuild content: "When is it appropriate to post to the following mailing lists: gentoo-core, gentoo-dev, gentoo-dev-announce, gentoo-project?" ebuild_q4: title: src_install documentation: GLEPs - question_category: ebuild + category: ebuild question_group: ebuild_group1 content: "\n src_install () { \n dobin uvconvert/${PN} @@ -35,7 +35,7 @@ ebuild_q4: ebuild_q5: title: src_install documentation: devmanual - question_category: ebuild + category: ebuild question_group: ebuild_group1 content: "\n src_install() { \n dobin utrac @@ -47,7 +47,7 @@ ebuild_q5: ebuild_q6: title: src_install documentation: handbook - question_category: ebuild + category: ebuild question_group: ebuild_group1 content: "\n src_install() { \n dobin tree @@ -58,13 +58,13 @@ ebuild_q6: mentor_q1: title: Scopes in ebuild documentation: handbook - question_category: mentoring + category: mentoring content: "What's the difference between local and global scope in an ebuild?" mentor_q2: title: Optional SSL support in ebuild documentation: devmanual - question_category: mentoring + category: mentoring content: 'You have a patch for foomatic which enables SSL support that is optional at build time. Assuming that foomatic uses an autotools based build system provide most probable changes required in an `EAPI="0"` ebuild. @@ -73,7 +73,7 @@ mentor_q2: mentor_q3: title: Improve maintainability of ebuild documentation: devmanual - question_category: mentoring + category: mentoring content: "You are writing an ebuild for the foomatic package. Upstream calls the current version \"1.3-7b\" (but this is _not_ a beta release). How would the ebuild be named? What's wrong with the ebuild snippet below and how should this @@ -84,12 +84,12 @@ mentor_q3: non_q1: title: Gentoo Foundation documentation: gentoo.org - question_category: non_ebuild + category: non_ebuild content: What is the Gentoo Foundation? How does one apply for membership and who are eligible? non_q2: title: Gentoo Council documentation: GLEPs - question_category: non_ebuild + category: non_ebuild content: What is the purpose of the Gentoo Council? diff --git a/db/migrate/20110312173240_rename_question_category_to_category.rb b/db/migrate/20110312173240_rename_question_category_to_category.rb new file mode 100644 index 0000000..e20fa72 --- /dev/null +++ b/db/migrate/20110312173240_rename_question_category_to_category.rb @@ -0,0 +1,29 @@ +class RenameQuestionCategoryToCategory < ActiveRecord::Migration + def self.up + rename_table :question_categories, :categories + + rename_column :questions, :question_category_id, :category_id + + rename_column :user_categories, :question_category_id, :category_id + + remove_index :questions, :name => :index_questions_on_question_category_id rescue ActiveRecord::StatementInvalid + add_index :questions, [:category_id] + + remove_index :user_categories, :name => :index_user_categories_on_question_category_id rescue ActiveRecord::StatementInvalid + add_index :user_categories, [:category_id] + end + + def self.down + rename_column :questions, :category_id, :question_category_id + + rename_column :user_categories, :category_id, :question_category_id + + rename_table :categories, :question_categories + + remove_index :questions, :name => :index_questions_on_category_id rescue ActiveRecord::StatementInvalid + add_index :questions, [:question_category_id] + + remove_index :user_categories, :name => :index_user_categories_on_category_id rescue ActiveRecord::StatementInvalid + add_index :user_categories, [:question_category_id] + end +end diff --git a/db/schema.rb b/db/schema.rb index 49089a1..cbdde12 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,7 +9,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20101211142354) do +ActiveRecord::Schema.define(:version => 20110312173240) do create_table "answers", :force => true do |t| t.text "content", :default => "", :null => false @@ -28,6 +28,12 @@ ActiveRecord::Schema.define(:version => 20101211142354) do add_index "answers", ["question_id"], :name => "index_answers_on_question_id" add_index "answers", ["type"], :name => "index_answers_on_type" + create_table "categories", :force => true do |t| + t.string "name", :null => false + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "comments", :force => true do |t| t.text "content", :null => false t.datetime "created_at" @@ -72,12 +78,6 @@ ActiveRecord::Schema.define(:version => 20101211142354) do add_index "project_acceptances", ["user_id"], :name => "index_project_acceptances_on_user_id" - create_table "question_categories", :force => true do |t| - t.string "name", :null => false - t.datetime "created_at" - t.datetime "updated_at" - end - create_table "question_content_emails", :force => true do |t| t.text "requirements", :default => "", :null => false t.text "description" @@ -114,28 +114,28 @@ ActiveRecord::Schema.define(:version => 20101211142354) do end create_table "questions", :force => true do |t| - t.string "title", :null => false + t.string "title", :null => false t.string "documentation" - t.boolean "approved", :default => false + t.boolean "approved", :default => false t.datetime "created_at" t.datetime "updated_at" t.integer "user_id" - t.integer "question_category_id" + t.integer "category_id" t.integer "question_group_id" end - add_index "questions", ["question_category_id"], :name => "index_questions_on_question_category_id" + add_index "questions", ["category_id"], :name => "index_questions_on_category_id" add_index "questions", ["question_group_id"], :name => "index_questions_on_question_group_id" add_index "questions", ["user_id"], :name => "index_questions_on_user_id" create_table "user_categories", :force => true do |t| t.datetime "created_at" t.datetime "updated_at" - t.integer "user_id", :null => false - t.integer "question_category_id", :null => false + t.integer "user_id", :null => false + t.integer "category_id", :null => false end - add_index "user_categories", ["question_category_id"], :name => "index_user_categories_on_question_category_id" + add_index "user_categories", ["category_id"], :name => "index_user_categories_on_category_id" add_index "user_categories", ["user_id"], :name => "index_user_categories_on_user_id" create_table "user_question_groups", :force => true do |t| diff --git a/db/seeds.rb b/db/seeds.rb index 4d06bc3..352cc18 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -46,7 +46,7 @@ APP_CONFIG['developer_data']['check'] = false # Remove existing database entries User.destroy_all Answer.destroy_all -QuestionCategory.destroy_all +Category.destroy_all QuestionGroup.destroy_all Question.destroy_all UserCategory.destroy_all @@ -56,21 +56,21 @@ User.destroy_all seeder = SeedHelper.new # Question categories -seeder.objects['ebuild'] = QuestionCategory.create! :name => 'Ebuild quiz' -seeder.objects['mentoring'] = QuestionCategory.create! :name => 'End of mentoring quiz' -seeder.objects['non'] = QuestionCategory.create! :name => 'Non-ebuild staff quiz' +seeder.objects['ebuild'] = Category.create! :name => 'Ebuild quiz' +seeder.objects['mentoring'] = Category.create! :name => 'End of mentoring quiz' +seeder.objects['non'] = Category.create! :name => 'Non-ebuild staff quiz' # Question groups seeder.objects['ebuild_group1'] = QuestionGroup.create! :name => 'ebuild_group1', :description => 'src_install implementations to comment on' # Questions with text content - load from YAML file -seeder.read_yaml('db/fixtures/questions.yml', Question, ['question_category', 'question_group']) do |name, hash, objects, klass| +seeder.read_yaml('db/fixtures/questions.yml', Question, ['category', 'question_group']) do |name, hash, objects, klass| objects[name] = klass.create! (hash - {'content' => nil}) objects["#{name}-content"] = QuestionContentText.create! :question => objects[name], :content => hash['content'] end # Questions with multiple choice content - load from YAML file -seeder.read_yaml('db/fixtures/questions-multichoice.yml', Question, ['question_category', 'question_group']) do |name, hash, objects, klass| +seeder.read_yaml('db/fixtures/questions-multichoice.yml', Question, ['category', 'question_group']) do |name, hash, objects, klass| objects[name] = klass.create!(hash - {'options' => nil, 'content' => nil}) objects["#{name}-content"] = QuestionContentMultipleChoice.create! :question => objects[name], :content => hash['content'] for opt in hash['options'].split(';') @@ -80,7 +80,7 @@ seeder.read_yaml('db/fixtures/questions-multichoice.yml', Question, ['question_c end # Questions with email content - load from YAML file -seeder.read_yaml('db/fixtures/questions-email.yml', Question, ['question_category', 'question_group']) do |name, hash, objects, klass| +seeder.read_yaml('db/fixtures/questions-email.yml', Question, ['category', 'question_group']) do |name, hash, objects, klass| objects[name] = klass.create!(hash - {'content' => nil, 'req_text' => nil}) objects["#{name}-content"] = QuestionContentEmail.create! :question => objects[name], :description=> hash['content'], :req_text => hash['req_text'] end @@ -97,7 +97,7 @@ user_cats = [ ['mentoring', 'mentor']] for uc in user_cats - UserCategory.create! :question_category => seeder.objects[uc[0]], :user => seeder.objects[uc[1]] + UserCategory.create! :category => seeder.objects[uc[0]], :user => seeder.objects[uc[1]] end |