From: antti_haapala Date: Sun, 29 Nov 2015 16:27:57 +0000 (+0000) Subject: prettier revision identifier (always exatly 12 hex digits long) with better guarantee... X-Git-Tag: rel_0_8_4~2^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2dcd72e840d8055ffa8efcf586f7e1cc7c475907;p=thirdparty%2Fsqlalchemy%2Falembic.git prettier revision identifier (always exatly 12 hex digits long) with better guaranteed entropy (the last 48 bits of a uuid4 are all random). Works everywhere where uuid module exists (2.5 -) Rationale: with the current code most revision ids start with 1, 2, 3 or 4, and there are far more collisions with 2 initial digits than necessary (cumbersome to check a file by revision on command line and such). So instead of revision ids that are 1-12 digits long with ~45 bits of information, lets just have them 12 digits long and contain full 48 bits of info. --- diff --git a/alembic/util/langhelpers.py b/alembic/util/langhelpers.py index 54e5e806..a556e943 100644 --- a/alembic/util/langhelpers.py +++ b/alembic/util/langhelpers.py @@ -182,8 +182,7 @@ def asbool(value): def rev_id(): - val = int(uuid.uuid4()) % 100000000000000 - return hex(val)[2:-1] + return uuid.uuid4().hex[-12:] def to_list(x, default=None):