Skip to content

Commit

Permalink
fix styling issues in migrations (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
devkral authored Dec 16, 2024
1 parent 20a75d9 commit 90d80d8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions edgy/cli/templates/default/script.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Create Date: ${create_date}
from edgy.utils.hashing import hash_to_identifier, hash_to_identifier_as_string
%>
from __future__ import annotations

from alembic import op
import sqlalchemy as sa
${imports if imports else ""}
Expand Down
1 change: 1 addition & 0 deletions edgy/cli/templates/plain/script.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Create Date: ${create_date}

"""
from __future__ import annotations

from alembic import op
import sqlalchemy as sa
${imports if imports else ""}
Expand Down
5 changes: 3 additions & 2 deletions edgy/cli/templates/url/script.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Create Date: ${create_date}
from edgy.utils.hashing import hash_to_identifier, hash_to_identifier_as_string
%>
from __future__ import annotations

from typing import TYPE_CHECKING, Optional

from alembic import op
Expand All @@ -28,15 +29,15 @@ depends_on = ${repr(depends_on)}
${hash_to_identifier_as_string}


def upgrade(url: Optional["DatabaseURL"] = None) -> None:
def upgrade(url: Optional[DatabaseURL] = None) -> None:
urlstring = "" if url is None else f"{url.username}:{url.netloc}"
# hash_to_identifier adds already an "_"
fn = globals().get(f"upgrade{hash_to_identifier(urlstring)}")
if fn is not None:
fn()


def downgrade(url: Optional["DatabaseURL"] = None) -> None:
def downgrade(url: Optional[DatabaseURL] = None) -> None:
urlstring = "" if url is None else f"{url.username}:{url.netloc}"
# hash_to_identifier adds already an "_"
fn = globals().get(f"downgrade{hash_to_identifier(urlstring)}")
Expand Down

0 comments on commit 90d80d8

Please sign in to comment.