aboutsummaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20110312181715_add_question_category_pivot.rb21
-rw-r--r--db/schema.rb11
2 files changed, 29 insertions, 3 deletions
diff --git a/db/migrate/20110312181715_add_question_category_pivot.rb b/db/migrate/20110312181715_add_question_category_pivot.rb
new file mode 100644
index 0000000..ef1a810
--- /dev/null
+++ b/db/migrate/20110312181715_add_question_category_pivot.rb
@@ -0,0 +1,21 @@
+class AddQuestionCategoryPivot < ActiveRecord::Migration
+ def self.up
+ create_table :question_categories do |t|
+ t.integer :question_id, :null => false
+ t.integer :category_id, :null => false
+ end
+ add_index :question_categories, [:question_id, :category_id], :unique => true
+
+ remove_column :questions, :category_id
+
+ remove_index :questions, :name => :index_questions_on_category_id rescue ActiveRecord::StatementInvalid
+ end
+
+ def self.down
+ add_column :questions, :category_id, :integer
+
+ drop_table :question_categories
+
+ add_index :questions, [:category_id]
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index cbdde12..140e762 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 => 20110312173240) do
+ActiveRecord::Schema.define(:version => 20110312181715) do
create_table "answers", :force => true do |t|
t.text "content", :default => "", :null => false
@@ -78,6 +78,13 @@ ActiveRecord::Schema.define(:version => 20110312173240) do
add_index "project_acceptances", ["user_id"], :name => "index_project_acceptances_on_user_id"
+ create_table "question_categories", :force => true do |t|
+ t.integer "question_id", :null => false
+ t.integer "category_id", :null => false
+ end
+
+ add_index "question_categories", ["question_id", "category_id"], :name => "index_question_categories_on_question_id_and_category_id", :unique => true
+
create_table "question_content_emails", :force => true do |t|
t.text "requirements", :default => "", :null => false
t.text "description"
@@ -120,11 +127,9 @@ ActiveRecord::Schema.define(:version => 20110312173240) do
t.datetime "created_at"
t.datetime "updated_at"
t.integer "user_id"
- t.integer "category_id"
t.integer "question_group_id"
end
- 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"