Add force_datetime_default_format options and tests #18
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.
This PR adds a new option that can deal with default dates. Sometimes when you use a
DateTime.current
or something similar in a migration as a default value for a datetime field, and have multiple people running that migration at a different time, it can be a source of merge conflicts. Ideally you'd not use aDateTime.current
in a migration, but it can happen.This new option -
force_datetime_default_format
- accepts aTime.new()
object and replaces ALL dates in the sql file with that date, making sure every team member has the same default. This is made as an option, because it's quite essential that you're able to decide what the new default will be.Alternatively, passing
true
to the option will leave the dates as they are, but cut out miliseconds from the sql dump - Postgres seems to sometimes add them and sometimes not and I haven't been able to find out why.Additionally, it adds RSpec tests for the new code and for some of the existing code as well - it's not perfect, but it's a start.