discourse/spec/lib
Krzysztof Kotlarek f69dacf979 FIX: Reconnect in restore process connects to correct DB (#8218)
Simplified flow of restore is like that
```
migrate_database
reconnect
extract_uploads
```

Problem with incorrect current database started with this fix https://github.com/discourse/discourse/commit/025d4ee91f4

Dump task is reconnecting to default database https://github.com/rails/rails/blob/master/activerecord/lib/active_record/railties/databases.rake#L429

And then, we are trying to reconnect to the original database with that code:
```
def reconnect_database
  log "Reconnecting to the database..."
  RailsMultisite::ConnectionManagement::establish_connection(db: @current_db)
end
```

This reconnect is not switching us back to correct database because of that check
https://github.com/discourse/rails_multisite/blob/master/lib/rails_multisite/connection_management.rb#L181
Basically, it finds existing handler and it thinks that we are connected to correct DB and this step can be skipped.

To solve it, we can reload RailsMultisite::ConnectionManagement which creates a new instance of that class
https://github.com/discourse/rails_multisite/blob/master/lib/rails_multisite/connection_management.rb#L38
2019-10-23 17:23:50 +11:00
..
backup_restore FIX: Reconnect in restore process connects to correct DB (#8218) 2019-10-23 17:23:50 +11:00
compression DEV: Split max decompressed setting for themes and backups (#8179) 2019-10-11 14:38:10 -03:00
content_security_policy FEATURE: allow plugins and themes to extend the default CSP (#6704) 2018-11-30 09:51:45 -05:00
i18n FIX: English locale must not fall back to any other locale 2019-06-07 21:53:01 +02:00
seed_data DEV: use #frozen_string_literal: true on all spec 2019-04-30 10:27:42 +10:00
site_settings FIX: Check for category conflicts in SiteSetting validations (#8137) 2019-10-06 20:50:07 +02:00
webauthn DEV: Upgrading Discourse to Zeitwerk (#8098) 2019-10-02 14:01:53 +10:00
browser_detection_spec.rb FIX: Detect DiscourseHub user agent. 2019-08-09 11:58:15 +03:00
content_security_policy_spec.rb FIX: Cleanup DiscoursePluginRegistry state after tests that use it 2019-09-20 13:32:54 +01:00
db_helper_spec.rb DEV: Upgrading Discourse to Zeitwerk (#8098) 2019-10-02 14:01:53 +10:00
encodings_spec.rb DEV: use #frozen_string_literal: true on all spec 2019-04-30 10:27:42 +10:00
introduction_updater_spec.rb DEV: use #frozen_string_literal: true on all spec 2019-04-30 10:27:42 +10:00
mini_sql_multisite_connection_spec.rb DEV: use #frozen_string_literal: true on all spec 2019-04-30 10:27:42 +10:00
search_spec.rb FIX: Update mapping between locales and Postgres dictionaries. (#7606) 2019-05-27 16:52:09 +03:00
theme_javascript_compiler_spec.rb DEV: Upgrading Discourse to Zeitwerk (#8098) 2019-10-02 14:01:53 +10:00
upload_creator_spec.rb FEATURE: Support private attachments when using S3 storage (#7677) 2019-06-06 13:27:24 +10:00
upload_recovery_spec.rb DEV: Upgrading Discourse to Zeitwerk (#8098) 2019-10-02 14:01:53 +10:00