-
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 SectionEdition's database collection from specialist_document_editions to manual_section_editions #897
Conversation
@floehopper This looks good - I agree with the choice of collection name. It feels odd that this app shares a database with other apps but hopefully this will make it more obvious where this collection is managed from to anyone looking at that DB. Are you reasonably confident that none of the other apps rely on this collection being named |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My comment shouldn't stop you merging this!
Thanks for reviewing.
I've created #893 to investigate using a separate DB.
Good point. I'm fairly confident. Historically I think
So all in all, I'm happy to go ahead and merge this. |
* 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.
I've just noticed that alphagov/govuk_content_models#324 did not remove manuals and that there is still a Looking at my copy of the production mongo db, it appears that both |
As far as I can see, manuals-frontend only uses the content store and not the content api and so I can't see how any other apps can be depending on the |
e14e57a
to
feb2d64
Compare
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 thanActiveRecord::ConnectionAdapters::SchemaStatements#rename_table
, because of an incompatibility (see Fix incompatibility between mongoid_rails_migrations and mongoid versions #896) betweenmongoid_rails_migrations
and the version ofmongoid
we are using which results in the following exception:SectionEdition
class and its call tostore_in
with the new collection name. This means that an emptymanual_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.