mbucc / shmig

Database migration tool written in BASH.
BSD 3-Clause "New" or "Revised" License
458 stars 49 forks source link

Pads version number with '0' #5

Closed hoegaarden closed 10 years ago

hoegaarden commented 10 years ago

needed, for example, when you have pseudo migrations like '0000000001-initial_schema.sql'

mbucc commented 10 years ago

If I read this correctly, this patch let's you can store a version like 1 in the schema_version table. Why did you need (or prefer) this over than using the current timestamp as the version?

hoegaarden commented 10 years ago

hi @mbucc ...

Yes, that's right, you can use versions like '1'. I use this, to make it very clear that this is a special migration. However, I think it's just an error, when the system falls over when the char-length of the migration version is smaller than 10 .. but that's my point of view ...

Bye

mbucc commented 10 years ago

OK, the downside of more lines of code is minor compared to the benefit. I don't see any risk. Committed, thanks.

hoegaarden commented 10 years ago

Thank you!

mbucc commented 10 years ago

Your patch made me wonder what would happen if someone inserted a version number that was really long, say 20 digits. I think this would break shmig; any new migrations would never be applied.

I should add a check constraint on schema_version.version that the integer must be less than or equal to NOW() + 10 seconds.

On Sep 25, 2014, at 2:57 AM, hoegaarden notifications@github.com wrote:

Thank you!

— Reply to this email directly or view it on GitHub.