-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support after_deploy() migrations after the delay has passed (#53)
* Convert Safe to a custom class rather than an enum. This allows us to specify and store the delay associated with after_deploy. This also adds a check to determine if migrations are using the enum style when it should be using the method definition. * Render a new message for delayed after_deploy migrations. * Support running the tests against multiple databases. This likely needs work around the coverage aggregation. * Add SafeMigration model with migration. * Support Safe.after_deploy() with a delay. * Limit mysql and postgres tests to python 3.10-3.12 as per tox limits * Use future type annotations until 3.8 is retired.
- Loading branch information
1 parent
dcb1cae
commit a41cebe
Showing
13 changed files
with
803 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,29 @@ | ||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass | ||
from datetime import timedelta | ||
from enum import Enum | ||
|
||
|
||
class Safe(Enum): | ||
class SafeEnum(Enum): | ||
always = "always" | ||
before_deploy = "before_deploy" | ||
after_deploy = "after_deploy" | ||
|
||
|
||
@dataclass | ||
class Safe: | ||
safe: SafeEnum | ||
delay: timedelta | None = None | ||
|
||
@classmethod | ||
def always(cls): | ||
return cls(safe=SafeEnum.always) | ||
|
||
@classmethod | ||
def before_deploy(cls): | ||
return cls(safe=SafeEnum.before_deploy) | ||
|
||
@classmethod | ||
def after_deploy(cls, *, delay: timedelta = None): | ||
return cls(safe=SafeEnum.after_deploy, delay=delay) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.