-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[Backport] Make milestones polymorphic #3057
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javierm
force-pushed
the
backport-make-milestones-polymorphic
branch
from
November 29, 2018 19:33
de1305e
to
37541bd
Compare
javierm
changed the title
[Backport] Make milestones polymorphic
[WIP] [Backport] Make milestones polymorphic
Nov 29, 2018
javierm
force-pushed
the
backport-make-milestones-polymorphic
branch
from
November 30, 2018 10:29
07904ec
to
e96e222
Compare
Generalize the BudgetInvestmentStatus model to Milestone::Status so it is not specific to budget investments, but can be used for any entity which has milestones. This is in preparation to make the Milestone model polymorphic and usable by entities other than budget investments.
Generalize the Budget::Investment::Milestone model to a polymorphic Milestone model so it can be used for entities other than Budget::Investment.
We also make the line shorter so rubocop doesn't complain.
We had a line which was too long according to rubocop, and simplifying the code makes the line shorter.
Calling `load_tasks` in several files made rails load the tasks several times, and so they were executed several times when called. Since the milestone migration can't be executed twice in a row (it would fail with duplicated ID records), loading the tasks several times made the milestone migrations task specs fail.
We'd rather keep the table so future data migrations work smoothly, so we change the migration in order to create the translation table without using models.
When we insert a record in PostgreSQL and we specify the ID, the internal ID sequence for that table isn't updated. In order to keep the original IDs so we didn't break any foreign keys, we specified the IDs when copying the table, resulting in a table having its ID sequence with a value of an existing record. When trying to insert a new record, we got a `PG::UniqueViolation` exception. Updating the sequence after the data migration might not be the most elegant solution, but it's easy to do and it's already been tested on a production environment.
javierm
force-pushed
the
backport-make-milestones-polymorphic
branch
from
November 30, 2018 13:15
e96e222
to
936cd3f
Compare
Using `Date.today` was making the spec fail around midnight.
javierm
force-pushed
the
backport-make-milestones-polymorphic
branch
2 times, most recently
from
November 30, 2018 15:49
2231d70
to
4419599
Compare
javierm
changed the title
[WIP] [Backport] Make milestones polymorphic
[Backport] Make milestones polymorphic
Nov 30, 2018
javierm
force-pushed
the
backport-make-milestones-polymorphic
branch
from
November 30, 2018 16:12
4419599
to
e5e871f
Compare
We were having problems under certain conditions with Travis and Knapsack where tasks were still being loaded twice and so they were being executed twice.
javierm
force-pushed
the
backport-make-milestones-polymorphic
branch
from
November 30, 2018 16:29
e5e871f
to
ea95760
Compare
decabeza
approved these changes
Nov 30, 2018
microweb10
approved these changes
Dec 4, 2018
voodoorai2000
approved these changes
Dec 5, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
References
Date.current
instead ofDate.today
AyuntamientoMadrid/consul#1726.Objectives
Make milestones polymorphic, so we can use them in proposals and legislation processes.
Notes
RAILS_ENV=production bin/rake milestones:migrate
.Even though this task should run smoothly and it doesn't delete old milestones data, we always recommend to backup your database before running any tasks dealing with data migration.