prefect.server.database.alembic_commands
alembic_downgrade(revision='-1', dry_run=False)
Run alembic downgrades on Prefect REST API database
Parameters:
Name | Type | Description | Default |
---|---|---|---|
revision
|
str
|
The revision passed to |
'-1'
|
dry_run
|
bool
|
Show what migrations would be made without applying them. Will emit sql statements to stdout. |
False
|
Source code in src/prefect/server/database/alembic_commands.py
67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
alembic_revision(message=None, autogenerate=False, **kwargs)
Create a new revision file for the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
Optional[str]
|
string message to apply to the revision. |
None
|
autogenerate
|
bool
|
whether or not to autogenerate the script from the database. |
False
|
Source code in src/prefect/server/database/alembic_commands.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
alembic_stamp(revision)
Stamp the revision table with the given revision; don't run any migrations
Parameters:
Name | Type | Description | Default |
---|---|---|---|
revision
|
The revision passed to |
required |
Source code in src/prefect/server/database/alembic_commands.py
101 102 103 104 105 106 107 108 109 110 111 112 |
|
alembic_upgrade(revision='head', dry_run=False)
Run alembic upgrades on Prefect REST API database
Parameters:
Name | Type | Description | Default |
---|---|---|---|
revision
|
str
|
The revision passed to |
'head'
|
dry_run
|
bool
|
Show what migrations would be made without applying them. Will emit sql statements to stdout. |
False
|
Source code in src/prefect/server/database/alembic_commands.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
with_alembic_lock(fn)
Decorator that prevents alembic commands from running concurrently. This is necessary because alembic uses a global configuration object that is not thread-safe.
This issue occurred in https://github.com/PrefectHQ/prefect-dask/pull/50, where
dask threads were simultaneously performing alembic upgrades, and causing
cryptic KeyError: 'config'
when del globals_[attr_name]
.
Source code in src/prefect/server/database/alembic_commands.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
|