File tree Expand file tree Collapse file tree 2 files changed +2
-15
lines changed Expand file tree Collapse file tree 2 files changed +2
-15
lines changed Original file line number Diff line number Diff line change @@ -94,20 +94,7 @@ def write_indexes(table)
94
94
next if index [ :primary ]
95
95
unique = index [ :unique ] ? "UNIQUE " : nil
96
96
97
- #MySQL allows an index name which could be equal to a table name, Postgres doesn't
98
- indexname = index [ :name ]
99
- if indexname . eql? ( table . name )
100
- indexnamenew = "#{ indexname } _index"
101
- puts "WARNING: index \" #{ indexname } \" equals table name. This is not allowed by postgres and will be renamed to \" #{ indexnamenew } \" "
102
- indexname = indexnamenew
103
- end
104
-
105
- if @conn . server_version < 80200
106
- @conn . exec ( "DROP INDEX #{ PGconn . quote_ident ( indexname ) } CASCADE;" ) if exists? ( indexname )
107
- else
108
- @conn . exec ( "DROP INDEX IF EXISTS #{ PGconn . quote_ident ( indexname ) } CASCADE;" )
109
- end
110
- @conn . exec ( "CREATE #{ unique } INDEX #{ PGconn . quote_ident ( indexname ) } ON #{ PGconn . quote_ident ( table . name ) } (#{ index [ :columns ] . map { |col | PGconn . quote_ident ( col ) } . join ( ", " ) } );" )
97
+ @conn . exec ( "CREATE #{ unique } INDEX ON #{ PGconn . quote_ident ( table . name ) } (#{ index [ :columns ] . map { |col | PGconn . quote_ident ( col ) } . join ( ", " ) } );" )
111
98
end
112
99
113
100
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