structure:dump task fails in Rails 4 if can't find schema_migrations to read from #14217

Closed
kramerdog opened this Issue Feb 27, 2014 · 4 comments

Comments

Projects
None yet
2 participants
@kramerdog

It is not clear to me why dumping a database using the databases.rake structure:dump task should ALWAYS have to write to schema_migrations (by calling ActiveRecord::Base.connection.dump_schema_information) if the database supports migrations as Postgres does.

Currently the task returns a fatal error if the schema_migrations table does not exist.

Firstly, and I am probably missing something here, why does the act of "dumping" a database count as a migration? As this task is included in the clone_structure task, by running my Cucumber test suite (which requires test:clone to create the test database) I am seemingly running a migration?

Secondly, shouldn't a missing schema_migrations table be handled more elegantly than via a fatal error.

Thirdly, it would be really helpful if there was an option to ""switch off" migrations for a database that supports migrations other than by monkey patching ActiveRecord::Base.connection.supports_migrations? or hacking the Rake tasks.

I am sure I am not alone in having use cases where I don't want to use database migrations? The workaround is to ensure that I always have a schema_migrations table even if I dont use it (no biggie I guess) but this issue has just been introduced in Rails 4 as my application worked without schema_migrations under Rails 3.2

@senny senny added the activerecord label Feb 27, 2014

@senny

This comment has been minimized.

Show comment
Hide comment
@senny

senny Feb 27, 2014

Member

Actually dumping a database does not count as running a migration but it tries du dump the full contents of the schema_migrations table. It's part of the database structure and needs to be restored alongside.

Of course this is currently not working if you are not using migrations at all. I think we might skip this step if the schema_migrations table does not exist. There should be no harm there. I'll take a look.

Member

senny commented Feb 27, 2014

Actually dumping a database does not count as running a migration but it tries du dump the full contents of the schema_migrations table. It's part of the database structure and needs to be restored alongside.

Of course this is currently not working if you are not using migrations at all. I think we might skip this step if the schema_migrations table does not exist. There should be no harm there. I'll take a look.

@kramerdog

This comment has been minimized.

Show comment
Hide comment
@kramerdog

kramerdog Feb 27, 2014

Hi Yves

Thanks for the response and explanation. I obviously didn't look closely
enough to correctly determine what is going on here. But if this could
avoid a fatal error if the table doesn't exist it would be good I think.

Cheers

On Thu, Feb 27, 2014 at 7:30 PM, Yves Senn notifications@github.com wrote:

Actually dumping a database does not count as running a migration but it
tries du dump the full contents of the schema_migrations table. It's part
of the database structure and needs to be restored alongside.

Of course this is currently not working if you are not using migrations at
all. I think we might skip this step if the schema_migrations table does
not exist. There should be no harm there. I'll take a look.

Reply to this email directly or view it on GitHubhttps://github.com/rails/rails/issues/14217#issuecomment-36224435
.

Hi Yves

Thanks for the response and explanation. I obviously didn't look closely
enough to correctly determine what is going on here. But if this could
avoid a fatal error if the table doesn't exist it would be good I think.

Cheers

On Thu, Feb 27, 2014 at 7:30 PM, Yves Senn notifications@github.com wrote:

Actually dumping a database does not count as running a migration but it
tries du dump the full contents of the schema_migrations table. It's part
of the database structure and needs to be restored alongside.

Of course this is currently not working if you are not using migrations at
all. I think we might skip this step if the schema_migrations table does
not exist. There should be no harm there. I'll take a look.

Reply to this email directly or view it on GitHubhttps://github.com/rails/rails/issues/14217#issuecomment-36224435
.

@senny senny closed this in eafec46 Mar 20, 2014

senny added a commit that referenced this issue Mar 20, 2014

senny added a commit that referenced this issue Mar 20, 2014

@senny

This comment has been minimized.

Show comment
Hide comment
@senny

senny Mar 20, 2014

Member

@kramerdog pushed a fix to master and backported to 4-0-stable and 4-1-stable.

Member

senny commented Mar 20, 2014

@kramerdog pushed a fix to master and backported to 4-0-stable and 4-1-stable.

@kramerdog

This comment has been minimized.

Show comment
Hide comment
@kramerdog

kramerdog Mar 31, 2014

Many thanks Yves.

A bit too late for 4.0.4 I think but hopefully in 4.0.5 or 4.1.1....

Cheers

Craig

On Thu, Mar 20, 2014 at 8:15 PM, Yves Senn notifications@github.com wrote:

@kramerdog https://github.com/kramerdog pushed a fix to master and
backported to 4-0-stable and 4-1-stable.

Reply to this email directly or view it on GitHubhttps://github.com/rails/rails/issues/14217#issuecomment-38151396
.

Many thanks Yves.

A bit too late for 4.0.4 I think but hopefully in 4.0.5 or 4.1.1....

Cheers

Craig

On Thu, Mar 20, 2014 at 8:15 PM, Yves Senn notifications@github.com wrote:

@kramerdog https://github.com/kramerdog pushed a fix to master and
backported to 4-0-stable and 4-1-stable.

Reply to this email directly or view it on GitHubhttps://github.com/rails/rails/issues/14217#issuecomment-38151396
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment