Skip to content
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

Add force_datetime_default_format options and tests #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marcinruszkiewicz
Copy link

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 a DateTime.current in a migration, but it can happen.

This new option - force_datetime_default_format - accepts a Time.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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant