summaryrefslogtreecommitdiff
path: root/alembic/script
diff options
context:
space:
mode:
authorCaio Carvalho <21188280+lowercase00@users.noreply.github.com>2022-05-03 13:20:18 -0400
committerFederico Caselli <cfederico87@gmail.com>2022-05-06 20:30:39 +0000
commit0adcc749183abe17beab0baa07d8b1b1ac6a55d2 (patch)
treeea0bf6b93cf6021db77a5f6ccf5fce43dc5b389a /alembic/script
parent1684d0ee89c0fc6b0b90bc5db614468b31119e9d (diff)
downloadalembic-0adcc749183abe17beab0baa07d8b1b1ac6a55d2.tar.gz
Add epoch as an option for file_template
Added new token ``epoch`` to the ``file_template`` option, which will populate the integer epoch as determined by ``int(create_date.timestamp())``. Pull request courtesy Caio Carvalho. Fixes: #1027 Closes: #1028 Pull-request: https://github.com/sqlalchemy/alembic/pull/1028 Pull-request-sha: 27970cd5d4e047cb7aabd161c68b757b2ee3e4c4 Change-Id: I73e13009bae91e64681a605b3f0b62ea1e5fc464
Diffstat (limited to 'alembic/script')
-rw-r--r--alembic/script/base.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/alembic/script/base.py b/alembic/script/base.py
index cd81f37..cae0a2b 100644
--- a/alembic/script/base.py
+++ b/alembic/script/base.py
@@ -771,6 +771,7 @@ class ScriptDirectory:
message: Optional[str],
create_date: "datetime.datetime",
) -> str:
+ epoch = int(create_date.timestamp())
slug = "_".join(_slug_re.findall(message or "")).lower()
if len(slug) > self.truncate_slug_length:
slug = slug[: self.truncate_slug_length].rsplit("_", 1)[0] + "_"
@@ -779,6 +780,7 @@ class ScriptDirectory:
% {
"rev": rev_id,
"slug": slug,
+ "epoch": epoch,
"year": create_date.year,
"month": create_date.month,
"day": create_date.day,