-
-
Notifications
You must be signed in to change notification settings - Fork 144
feat(database): add configurable migration naming strategy #1928
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
Conversation
|
I love this. What if the interface accepted the filename so the user could have further control over the final name? |
Only the filename, or a separate property? |
|
I meant this: interface MigrationNamingStrategy
{
public function getName(string $filename): string;
}Not sure if the extension should be given too? |
Makes sense, I can definitely adapt to this. However,
I don't think so, What are your thoughts? |
Ah, good point! I'd say we only use the naming strategy for raw migrations because class ones should follow PSR-4. That would also solve the extension question. |
|
Nice, @xHeaven! I really like this PR also. Given this is merged to 3.x, any reason we cannot a) default to UUIDv7 and b) add a timestamp to the date? CC: @innocenzi |
There is no reason. I was unsure whether I wanted to change Tempest's default behavior, as people tend to have some weird UX fetish towards date'd migrations, for "scannability" reasons. We can definitely default to UUIDv7, in fact, it's a safer default in terms of collisions. Regarding the timestamp to date, we could either rename the |
|
Personally I wouldn't want UUIDs by default, it's not exactly nice to "scan" when looking at the file tree. It's quite long and I'm more interested in seeing the rest of the name :) |
|
A Unix timestamp strategy would be good though! |
See @aidan-casey, there goes the scanning fetish I was talking about! :D |
|
Sadness. I like the lack of collision while maintaining sorting by time. It'd be nice if you could generate multiple migrations at a time and have them all sorted by order. Either way, I think we should include a sensible default, which should at least not collide when created on the same day by default. |
|
That's still possible without cluttering file names with UUIDs! We could do a |
This PR makes the filename prefix configurable for
rawmigrations.Keeps the original
Y-m-dprefix and adds a newUuidv7prefix. (time-sortable)The usecase: no collision/confusion/rename need when creating multiple migrations the same day.