Permalink
Browse files

index dump should not include full text indexes. Thanks Ken Mayer for…

… the original patch! [#4949 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
tenderlove authored and josevalim committed Jun 25, 2010
1 parent 65aa6a7 commit 4464d10e68045e6723d4eb62734213c4296ef339
@@ -609,9 +609,7 @@ def indexes(table_name, name = nil)
SQL
- indexes = []
-
- indexes = result.map do |row|
+ result.map do |row|
index_name = row[0]
unique = row[1] == 't'
indkey = row[2].split(" ")
@@ -625,11 +623,8 @@ def indexes(table_name, name = nil)
SQL
column_names = indkey.map {|attnum| columns[attnum] }
- IndexDefinition.new(table_name, index_name, unique, column_names)
-
- end
-
- indexes
+ column_names.compact.empty? ? nil : IndexDefinition.new(table_name, index_name, unique, column_names)
+ end.compact
end
# Returns the list of all column definitions for a table.
@@ -9,9 +9,11 @@ class SchemaTest < ActiveRecord::TestCase
CAPITALIZED_TABLE_NAME = 'Things'
INDEX_A_NAME = 'a_index_things_on_name'
INDEX_B_NAME = 'b_index_things_on_different_columns_in_each_schema'
+ INDEX_C_NAME = 'c_index_full_text_search'
INDEX_A_COLUMN = 'name'
INDEX_B_COLUMN_S1 = 'email'
INDEX_B_COLUMN_S2 = 'moment'
+ INDEX_C_COLUMN = %q{(to_tsvector('english', coalesce(things.name, '')))}
COLUMNS = [
'id integer',
'name character varying(50)',
@@ -45,6 +47,8 @@ def setup
@connection.execute "CREATE INDEX #{INDEX_A_NAME} ON #{SCHEMA2_NAME}.#{TABLE_NAME} USING btree (#{INDEX_A_COLUMN});"
@connection.execute "CREATE INDEX #{INDEX_B_NAME} ON #{SCHEMA_NAME}.#{TABLE_NAME} USING btree (#{INDEX_B_COLUMN_S1});"
@connection.execute "CREATE INDEX #{INDEX_B_NAME} ON #{SCHEMA2_NAME}.#{TABLE_NAME} USING btree (#{INDEX_B_COLUMN_S2});"
+ @connection.execute "CREATE INDEX #{INDEX_C_NAME} ON #{SCHEMA_NAME}.#{TABLE_NAME} USING gin (#{INDEX_C_COLUMN});"
+ @connection.execute "CREATE INDEX #{INDEX_C_NAME} ON #{SCHEMA2_NAME}.#{TABLE_NAME} USING gin (#{INDEX_C_COLUMN});"
end
def teardown

0 comments on commit 4464d10

Please sign in to comment.