-
Notifications
You must be signed in to change notification settings - Fork 16
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
Rename the specialist_document_editions Mongo collection #848
Comments
floehopper
added a commit
that referenced
this issue
Mar 21, 2017
* The new name more closely matches the model class name and removes one of the last vestiges of specialist documents in the app. * I've prefixed the new collection name with "manual" rather than just using "section_editions", because it turns out that this app is sharing a database with a number of other apps, e.g. Publisher, and I felt as if "section_editions" was too generic and might lead to confusion. * I've used methods on `Mongoid::DB` rather than `ActiveRecord::ConnectionAdapters::SchemaStatements#rename_table`, because of an incompatibility (see #896) between `mongoid_rails_migrations` and the version of `mongoid` we are using which results in the following exception: NoMethodError: undefined method `default_session' for Mongoid:Module * I've had to include code to drop the target collection if it exists and is empty before doing the rename, because it appears that something (presumably Mongoid) is creating the collection on application startup based on the existence of the `SectionEdition` class and its call to `store_in` with the new collection name. This means that an empty `manual_section_editions` collection is created before the migration is run and if we didn't drop the collection, the rename would fail. I'm only doing this if the collection is empty, on the off-chance that the collection really exists and contains some important data. Closes #848.
floehopper
added a commit
that referenced
this issue
Mar 21, 2017
* The new name more closely matches the model class name and removes one of the last vestiges of specialist documents in the app. * I've prefixed the new collection name with "manual" rather than just using "section_editions", because it turns out that this app is sharing a database with a number of other apps, e.g. Publisher, and I felt as if "section_editions" was too generic and might lead to confusion. * I've used methods on `Mongoid::DB` rather than `ActiveRecord::ConnectionAdapters::SchemaStatements#rename_table`, because of an incompatibility (see #896) between `mongoid_rails_migrations` and the version of `mongoid` we are using which results in the following exception: NoMethodError: undefined method `default_session' for Mongoid:Module * I've had to include code to drop the target collection if it exists and is empty before doing the rename, because it appears that something (presumably Mongoid) is creating the collection on application startup based on the existence of the `SectionEdition` class and its call to `store_in` with the new collection name. This means that an empty `manual_section_editions` collection is created before the migration is run and if we didn't drop the collection, the rename would fail. I'm only doing this if the collection is empty, on the off-chance that the collection really exists and contains some important data. Closes #848.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PR #837 renames
SpecialistDocumentEdition
toSectionEdition
but the data is still stored in thespecialist_document_editions
Mongo collection.We should rename the collection to
section_editions
once PR #837 has been merged.The text was updated successfully, but these errors were encountered: