Skip to content

Commit

Permalink
Taggable should be an integer.
Browse files Browse the repository at this point in the history
  • Loading branch information
tpendragon committed May 26, 2016
1 parent dd4b6c2 commit 19b5337
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions db/migrate/20160526233455_taggable_id_integer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class TaggableIdInteger < ActiveRecord::Migration
def up
if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
change_column :taggings, :taggable_id, 'integer USING CAST("column_to_change" AS integer)'
else
change_column :taggings, :taggable_id, :integer
end
end

def down
change_column :taggings, :taggable_id, :string
end
end
4 changes: 2 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160330215214) do
ActiveRecord::Schema.define(version: 20160526233455) do

create_table "bookmarks", force: :cascade do |t|
t.integer "user_id", null: false
Expand Down Expand Up @@ -275,7 +275,7 @@

create_table "taggings", force: :cascade do |t|
t.integer "tag_id"
t.string "taggable_id"
t.integer "taggable_id"
t.string "taggable_type"
t.integer "tagger_id"
t.string "tagger_type"
Expand Down

0 comments on commit 19b5337

Please sign in to comment.