Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

purge database before loading schema, take 2 #16316

Merged
merged 2 commits into from
Aug 6, 2014

Conversation

senny
Copy link
Member

@senny senny commented Jul 28, 2014

This brings back the behavior introduced by #15394 which was reverted with 5c87b5c

The original patch introduced regressions where the wrong database was purged before loading the schema. The rake tasks no longer open specific connections but tell DatabaseTasks on what configuration to act on.

I had to create a temporary method load_schema_for because DatabaseTasks is public API and load_schema needs a new first argument. After the deprecation cycle we can rename load_schema_for back to load_schema.

This functionality is required to for the foreign key support of schema.rb.

I can squash the commits if necessary but wanted to have the diff to the patch explicit for the review.

@senny senny added this to the 4.2.0 milestone Jul 28, 2014
@senny
Copy link
Member Author

senny commented Jul 28, 2014

I ran Sam's tests against this branch and the output is consistent with master.

@rubys could you run your tests against this branch as well? Just to make sure I did not mess up when running them in my environment 😓

@dhh could you test wether this branch solves your reported issues with the original patch?

@rafaelfranca could you take a look?

@rubys
Copy link
Contributor

rubys commented Jul 28, 2014

I also get test results when running on this branch that are consistent with master (3 known failures due to ruby-i18n/i18n#275).

@rafaelfranca
Copy link
Member

:shipit:

…maintaining-test-schema-for-sql-format""

This reverts commit 5c87b5c.
The rake tasks and the `DatabaseTakss` adapter classes used to
assume a configuration at some places. This forced the rake
tasks to establish a specific connection before calling into
`load_schema`.

After #15394 this started to cause issues because it could
`purge` the wrong database before loading the schema.
senny added a commit that referenced this pull request Aug 6, 2014
purge database before loading schema, take 2
@senny senny merged commit ec54acd into master Aug 6, 2014
@senny senny deleted the senny/purge_schema_maintenance branch August 6, 2014 06:26
@jaredbeck
Copy link
Contributor

Here's a workaround for rails 4.1 (+postgres) users who want to use maintain_test_schema! in the meantime, while we wait for 4.2.

# Put in spec_helper, before call to ActiveRecord::Migration.maintain_test_schema!
if ActiveRecord::Migrator.needs_migration?
  puts('Needs migrations, purging test database ..')
  ActiveRecord::Tasks::PostgreSQLDatabaseTasks
    .new(ActiveRecord::Base.configurations.fetch('test'))
    .purge
end

senny added a commit that referenced this pull request Aug 27, 2014
purge database before loading schema, take 2
Conflicts:
	activerecord/CHANGELOG.md
	activerecord/lib/active_record/tasks/database_tasks.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants