From 2dcd72e840d8055ffa8efcf586f7e1cc7c475907 Mon Sep 17 00:00:00 2001 From: antti_haapala Date: Sun, 29 Nov 2015 16:27:57 +0000 Subject: [PATCH] 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. --- alembic/util/langhelpers.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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): -- 2.47.2