Skip to content

Commit 560cc01

Browse files
committed
Merge pull request #1404 from projectblacklight/db-migrations
Update database migrations to build the expected table structure from the start
2 parents 68b2a53 + 11cf9bc commit 560cc01

3 files changed

+6
-7
lines changed

db/migrate/20140202020201_create_searches.rb

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ class CreateSearches < ActiveRecord::Migration
33
def self.up
44
create_table :searches do |t|
55
t.text :query_params
6-
t.integer :user_id
6+
t.integer :user_id, index: true
77
t.string :user_type
88

99
t.timestamps null: false
1010
end
11-
12-
add_index :searches, :user_id
1311
end
1412

1513
def self.down

db/migrate/20140202020202_create_bookmarks.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
class CreateBookmarks < ActiveRecord::Migration
33
def self.up
44
create_table :bookmarks do |t|
5-
t.integer :user_id, :null=>false
5+
t.integer :user_id, index: true, null: false
66
t.string :user_type
7-
t.string :document_id
7+
t.string :document_id, index: true
8+
t.string :document_type
89
t.string :title
910
t.timestamps null: false
1011
end
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# frozen_string_literal: true
22
class AddPolymorphicTypeToBookmarks < ActiveRecord::Migration
33
def change
4-
add_column(:bookmarks, :document_type, :string)
4+
add_column(:bookmarks, :document_type, :string) unless Bookmark.connection.column_exists? :bookmarks, :document_type
55

6-
add_index :bookmarks, :user_id
6+
add_index :bookmarks, :user_id unless Bookmark.connection.index_exists? :bookmarks, :user_id
77
end
88
end

0 commit comments

Comments
 (0)