Skip to content

Commit

Permalink
Update database migrations to build the expected table structure from…
Browse files Browse the repository at this point in the history
… the start
  • Loading branch information
cbeer committed Apr 19, 2016
1 parent 2d376e8 commit 9a93724
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion db/migrate/20140202020201_create_searches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class CreateSearches < ActiveRecord::Migration
def self.up
create_table :searches do |t|
t.text :query_params
t.integer :user_id
t.integer :user_id, index: true, null: false
t.string :user_type

t.timestamps null: false
Expand Down
5 changes: 3 additions & 2 deletions db/migrate/20140202020202_create_bookmarks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
class CreateBookmarks < ActiveRecord::Migration
def self.up
create_table :bookmarks do |t|
t.integer :user_id, :null=>false
t.integer :user_id, index: true, null: false
t.string :user_type
t.string :document_id
t.string :document_id, index: true
t.string :document_type
t.string :title
t.timestamps null: false
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# frozen_string_literal: true
class AddPolymorphicTypeToBookmarks < ActiveRecord::Migration
def change
add_column(:bookmarks, :document_type, :string)
commit_db_transaction

add_column(:bookmarks, :document_type, :string) unless Bookmarks.connection.column_exists? :bookmarks, :user_id

add_index :bookmarks, :user_id
add_index :bookmarks, :user_id unless Bookmarks.connection.index_exists? :bookmarks, :user_id
end
end

0 comments on commit 9a93724

Please sign in to comment.