File tree 2 files changed +2
-15
lines changed
2 files changed +2
-15
lines changed Original file line number Diff line number Diff line change @@ -102,20 +102,7 @@ def write_indexes(table)
102
102
next if index [ :primary ]
103
103
unique = index [ :unique ] ? "UNIQUE " : nil
104
104
105
- #MySQL allows an index name which could be equal to a table name, Postgres doesn't
106
- indexname = index [ :name ]
107
- if indexname . eql? ( table . name )
108
- indexnamenew = "#{ indexname } _index"
109
- puts "WARNING: index \" #{ indexname } \" equals table name. This is not allowed by postgres and will be renamed to \" #{ indexnamenew } \" "
110
- indexname = indexnamenew
111
- end
112
-
113
- if @conn . server_version < 80200
114
- @conn . exec ( "DROP INDEX #{ PGconn . quote_ident ( indexname ) } CASCADE;" ) if exists? ( indexname )
115
- else
116
- @conn . exec ( "DROP INDEX IF EXISTS #{ PGconn . quote_ident ( indexname ) } CASCADE;" )
117
- end
118
- @conn . exec ( "CREATE #{ unique } INDEX #{ PGconn . quote_ident ( indexname ) } ON #{ PGconn . quote_ident ( table . name ) } (#{ index [ :columns ] . map { |col | PGconn . quote_ident ( col ) } . join ( ", " ) } );" )
105
+ @conn . exec ( "CREATE #{ unique } INDEX ON #{ PGconn . quote_ident ( table . name ) } (#{ index [ :columns ] . map { |col | PGconn . quote_ident ( col ) } . join ( ", " ) } );" )
119
106
end
120
107
121
108
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ def test_datetime_defaults
102
102
103
103
def test_index_conversion
104
104
result = exec_sql_on_psql ( 'SELECT pg_get_indexdef(indexrelid) FROM pg_index WHERE indrelid = \'test_index_conversion\'::regclass' ) . first
105
- assert_equal "CREATE UNIQUE INDEX test_index_conversion_index ON test_index_conversion USING btree (column_a)" , result [ "pg_get_indexdef" ]
105
+ assert_equal "CREATE UNIQUE INDEX test_index_conversion_column_a_idx ON test_index_conversion USING btree (column_a)" , result [ "pg_get_indexdef" ]
106
106
end
107
107
108
108
def test_foreign_keys
You can’t perform that action at this time.
0 commit comments