Skip to content

"No such column" when renaming some columns in the migrations #237

@jacob-carlborg

Description

@jacob-carlborg

I'm updating our Rails application from 2.3 to 3.2.8. We have some problem running the migrations. For some of the renames in the migrations we get an error message: "No such column". I've debugged the issue and it seems there's some kind of problem with the schema cache. If I add a debugger just before the following exception is raised:

https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/master/lib/active_record/connection_adapters/sqlserver/schema_statements.rb#L282

If I then, in the debugger, run schema_cache.columns[table_name].length I get back 5. But when I run columns(table_name).length I get back 24. When I call columns I can see in the returned value that it do contains the column we want to rename. So it seems the schema cache isn't updated correctly, for some reason.

I don't know if it matters but we have migrations both with the old style, just an incremented number in the name of the migration. And the current style with a date and a number.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions