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

Feature request: Timestamps instead of incrementing ids #86

Open
NoahTheDuke opened this issue Mar 6, 2024 · 2 comments
Open

Feature request: Timestamps instead of incrementing ids #86

NoahTheDuke opened this issue Mar 6, 2024 · 2 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@NoahTheDuke
Copy link

This library looks super cool, thanks for building it.

I work in a large engineering org with multiple teams. We use migratus which uses timestamps as the migration "number". This means that no matter how many people generate migrations on separate branches, there's no conflicts when they're merged to main.

Is there planned support for using timestamps (ISO 8601) as the number instead of a padded integer?

@abogoyavlensky abogoyavlensky added the enhancement New feature or request label Mar 6, 2024
@abogoyavlensky
Copy link
Owner

@NoahTheDuke Hi! Thank you for the feedback and for creating the first issue!

I considered using timestamps instead of incremented integers as the number of a migration version when I was building this part of the library, but decided to go with integer numbers. The reason involves a couple of considerations:

  • from my point of view, the application order of migrations should be predictable and explicit;
    • with timestamps, there's a possible scenario where a merged and already applied migration in the main branch has a more recent timestamp than the migration from a PR; in this case, the migration with the older timestamp would be applied in the wrong order according to the timestamps;
  • this approach (with an unfixed order of migration application) works well if migrations don't depend on each other, for example, for different tables; but sometimes if migrations relate to the same table or same columns, they must be applied in a particular order; the approach with incremented integer numbers guarantees this, whereas with timestamps you have to track it on your own;
  • the integer number of a migration is useful for the explain command and for migrating in forward or backward directions to a particular migration.

The downside is that before merging a PR, we have to ensure that there is no clash in migration numbers. The good part is that Automigrate has validation for this and will notify about duplicated migration numbers.


I think, we can keep this issue for a while in case there are other solutions on this to consider or discuss.

@NoahTheDuke
Copy link
Author

The downside is that before merging a PR, we have to ensure that there is no clash in migration numbers.

For our use-case, this would be a massive issue. We merge changesets to main 10+ times a day, and any number of them will have migrations. If we had to rebase/update every time someone merged, we'd be significantly slowed down.

I don't see us switching either way, we're tied to migratus, so don't rush to make any changes for us. I just want to make you aware of the trade offs here.

@abogoyavlensky abogoyavlensky added the question Further information is requested label Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants