discourse/spec
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
..
components DEV: waiting for 10ms is hardly enough 2019-10-23 16:18:41 +11:00
fabricators FEATURE: Webauthn authenticator management with 2FA login (Security Keys) (#8099) 2019-10-01 19:08:41 -07:00
fixtures FIX: Allow themes to upload and serve js files (#8188) 2019-10-14 15:40:33 +11:00
helpers FIX: Fallback to gzip compression if brotli isn't supported (#7895) 2019-07-16 11:05:37 -03:00
import_export DEV: clean up dependencies in spec 2019-10-02 14:50:54 +10:00
integration FIX: tag cannot be used if it belongs to two tag groups with parent tag 2019-10-16 14:28:04 -04:00
integrity DEV: Update markdown-it from 8.4.1 to 10.0.0 (#8164) 2019-10-08 13:00:22 +02:00
jobs DEV: Fix heisentest (ensure that user ID really does not exist). 2019-10-14 12:25:43 +03:00
lib FIX: Reconnect in restore process connects to correct DB (#8218) 2019-10-23 17:23:50 +11:00
mailers DEV: Upgrade Discourse to Rails 6 (#8083) 2019-09-12 10:41:50 +10:00
models DEV: Add test. 2019-10-21 21:33:58 +03:00
multisite DEV: Upgrading Discourse to Zeitwerk (#8098) 2019-10-02 14:01:53 +10:00
requests FIX: Prevent null-byte searches causing 500 error (#8226) 2019-10-22 08:44:52 -06:00
serializers FEATURE: Include image url in topic serializer 2019-10-21 22:02:49 -06:00
services DEV: pluck_first 2019-10-21 12:08:20 +01:00
support FIX: DistributedMutex (#7953) 2019-08-01 09:12:05 +01:00
tasks FEATURE: option to skip posts with ignored missing uploads 2019-05-09 05:11:15 +05:30
views/omniauth_callbacks FEATURE: Use full page redirection for all external auth methods (#8092) 2019-10-08 12:10:43 +01:00
rails_helper.rb DEV: Upgrading Discourse to Zeitwerk (#8098) 2019-10-02 14:01:53 +10:00