alembic 1.15.0__py3-none-any.whl → 1.15.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- alembic/__init__.py +1 -1
- alembic/autogenerate/render.py +3 -0
- alembic/ddl/base.py +5 -1
- alembic/ddl/impl.py +1 -2
- alembic/op.pyi +2 -2
- alembic/operations/base.py +4 -2
- alembic/operations/ops.py +5 -3
- alembic/templates/async/README +1 -0
- alembic/templates/async/alembic.ini.mako +117 -0
- alembic/templates/async/script.py.mako +28 -0
- alembic/templates/generic/README +1 -0
- alembic/templates/generic/alembic.ini.mako +119 -0
- alembic/templates/generic/script.py.mako +28 -0
- alembic/templates/multidb/README +12 -0
- alembic/templates/multidb/alembic.ini.mako +124 -0
- alembic/templates/multidb/script.py.mako +51 -0
- {alembic-1.15.0.dist-info → alembic-1.15.2.dist-info}/METADATA +3 -2
- {alembic-1.15.0.dist-info → alembic-1.15.2.dist-info}/RECORD +22 -13
- {alembic-1.15.0.dist-info → alembic-1.15.2.dist-info}/WHEEL +1 -1
- {alembic-1.15.0.dist-info → alembic-1.15.2.dist-info}/entry_points.txt +0 -0
- {alembic-1.15.0.dist-info → alembic-1.15.2.dist-info/licenses}/LICENSE +0 -0
- {alembic-1.15.0.dist-info → alembic-1.15.2.dist-info}/top_level.txt +0 -0
alembic/__init__.py
CHANGED
alembic/autogenerate/render.py
CHANGED
@@ -505,6 +505,7 @@ def _alter_column(
|
|
505
505
|
type_ = op.modify_type
|
506
506
|
nullable = op.modify_nullable
|
507
507
|
comment = op.modify_comment
|
508
|
+
newname = op.modify_name
|
508
509
|
autoincrement = op.kw.get("autoincrement", None)
|
509
510
|
existing_type = op.existing_type
|
510
511
|
existing_nullable = op.existing_nullable
|
@@ -533,6 +534,8 @@ def _alter_column(
|
|
533
534
|
rendered = _render_server_default(server_default, autogen_context)
|
534
535
|
text += ",\n%sserver_default=%s" % (indent, rendered)
|
535
536
|
|
537
|
+
if newname is not None:
|
538
|
+
text += ",\n%snew_column_name=%r" % (indent, newname)
|
536
539
|
if type_ is not None:
|
537
540
|
text += ",\n%stype_=%s" % (indent, _repr_type(type_, autogen_context))
|
538
541
|
if nullable is not None:
|
alembic/ddl/base.py
CHANGED
@@ -299,9 +299,13 @@ def format_server_default(
|
|
299
299
|
compiler: DDLCompiler,
|
300
300
|
default: Optional[_ServerDefault],
|
301
301
|
) -> str:
|
302
|
-
|
302
|
+
# this can be updated to use compiler.render_default_string
|
303
|
+
# for SQLAlchemy 2.0 and above; not in 1.4
|
304
|
+
default_str = compiler.get_column_default_string(
|
303
305
|
Column("x", Integer, server_default=default)
|
304
306
|
)
|
307
|
+
assert default_str is not None
|
308
|
+
return default_str
|
305
309
|
|
306
310
|
|
307
311
|
def format_type(compiler: DDLCompiler, type_: TypeEngine) -> str:
|
alembic/ddl/impl.py
CHANGED
@@ -46,7 +46,6 @@ if TYPE_CHECKING:
|
|
46
46
|
from sqlalchemy.engine.reflection import Inspector
|
47
47
|
from sqlalchemy.sql import ClauseElement
|
48
48
|
from sqlalchemy.sql import Executable
|
49
|
-
from sqlalchemy.sql.elements import ColumnElement
|
50
49
|
from sqlalchemy.sql.elements import quoted_name
|
51
50
|
from sqlalchemy.sql.schema import Constraint
|
52
51
|
from sqlalchemy.sql.schema import ForeignKeyConstraint
|
@@ -440,7 +439,7 @@ class DefaultImpl(metaclass=ImplMeta):
|
|
440
439
|
def drop_table_comment(self, table: Table) -> None:
|
441
440
|
self._exec(schema.DropTableComment(table))
|
442
441
|
|
443
|
-
def create_column_comment(self, column:
|
442
|
+
def create_column_comment(self, column: Column[Any]) -> None:
|
444
443
|
self._exec(schema.SetColumnComment(column))
|
445
444
|
|
446
445
|
def drop_index(self, index: Index, **kw: Any) -> None:
|
alembic/op.pyi
CHANGED
@@ -146,12 +146,12 @@ def alter_column(
|
|
146
146
|
*,
|
147
147
|
nullable: Optional[bool] = None,
|
148
148
|
comment: Union[str, Literal[False], None] = False,
|
149
|
-
server_default:
|
149
|
+
server_default: Union[str, bool, Identity, Computed, TextClause] = False,
|
150
150
|
new_column_name: Optional[str] = None,
|
151
151
|
type_: Union[TypeEngine[Any], Type[TypeEngine[Any]], None] = None,
|
152
152
|
existing_type: Union[TypeEngine[Any], Type[TypeEngine[Any]], None] = None,
|
153
153
|
existing_server_default: Union[
|
154
|
-
str, bool, Identity, Computed, None
|
154
|
+
str, bool, Identity, Computed, TextClause, None
|
155
155
|
] = False,
|
156
156
|
existing_nullable: Optional[bool] = None,
|
157
157
|
existing_comment: Optional[str] = None,
|
alembic/operations/base.py
CHANGED
@@ -705,14 +705,16 @@ class Operations(AbstractOperations):
|
|
705
705
|
*,
|
706
706
|
nullable: Optional[bool] = None,
|
707
707
|
comment: Union[str, Literal[False], None] = False,
|
708
|
-
server_default:
|
708
|
+
server_default: Union[
|
709
|
+
str, bool, Identity, Computed, TextClause
|
710
|
+
] = False,
|
709
711
|
new_column_name: Optional[str] = None,
|
710
712
|
type_: Union[TypeEngine[Any], Type[TypeEngine[Any]], None] = None,
|
711
713
|
existing_type: Union[
|
712
714
|
TypeEngine[Any], Type[TypeEngine[Any]], None
|
713
715
|
] = None,
|
714
716
|
existing_server_default: Union[
|
715
|
-
str, bool, Identity, Computed, None
|
717
|
+
str, bool, Identity, Computed, TextClause, None
|
716
718
|
] = False,
|
717
719
|
existing_nullable: Optional[bool] = None,
|
718
720
|
existing_comment: Optional[str] = None,
|
alembic/operations/ops.py
CHANGED
@@ -1840,14 +1840,16 @@ class AlterColumnOp(AlterTableOp):
|
|
1840
1840
|
*,
|
1841
1841
|
nullable: Optional[bool] = None,
|
1842
1842
|
comment: Optional[Union[str, Literal[False]]] = False,
|
1843
|
-
server_default:
|
1843
|
+
server_default: Union[
|
1844
|
+
str, bool, Identity, Computed, TextClause
|
1845
|
+
] = False,
|
1844
1846
|
new_column_name: Optional[str] = None,
|
1845
1847
|
type_: Optional[Union[TypeEngine[Any], Type[TypeEngine[Any]]]] = None,
|
1846
1848
|
existing_type: Optional[
|
1847
1849
|
Union[TypeEngine[Any], Type[TypeEngine[Any]]]
|
1848
1850
|
] = None,
|
1849
|
-
existing_server_default:
|
1850
|
-
|
1851
|
+
existing_server_default: Union[
|
1852
|
+
str, bool, Identity, Computed, TextClause, None
|
1851
1853
|
] = False,
|
1852
1854
|
existing_nullable: Optional[bool] = None,
|
1853
1855
|
existing_comment: Optional[str] = None,
|
@@ -0,0 +1 @@
|
|
1
|
+
Generic single-database configuration with an async dbapi.
|
@@ -0,0 +1,117 @@
|
|
1
|
+
# A generic, single database configuration.
|
2
|
+
|
3
|
+
[alembic]
|
4
|
+
# path to migration scripts.
|
5
|
+
# Use forward slashes (/) also on windows to provide an os agnostic path
|
6
|
+
script_location = ${script_location}
|
7
|
+
|
8
|
+
# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
|
9
|
+
# Uncomment the line below if you want the files to be prepended with date and time
|
10
|
+
# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s
|
11
|
+
|
12
|
+
# sys.path path, will be prepended to sys.path if present.
|
13
|
+
# defaults to the current working directory.
|
14
|
+
prepend_sys_path = .
|
15
|
+
|
16
|
+
# timezone to use when rendering the date within the migration file
|
17
|
+
# as well as the filename.
|
18
|
+
# If specified, requires the python>=3.9 or backports.zoneinfo library and tzdata library.
|
19
|
+
# Any required deps can installed by adding `alembic[tz]` to the pip requirements
|
20
|
+
# string value is passed to ZoneInfo()
|
21
|
+
# leave blank for localtime
|
22
|
+
# timezone =
|
23
|
+
|
24
|
+
# max length of characters to apply to the "slug" field
|
25
|
+
# truncate_slug_length = 40
|
26
|
+
|
27
|
+
# set to 'true' to run the environment during
|
28
|
+
# the 'revision' command, regardless of autogenerate
|
29
|
+
# revision_environment = false
|
30
|
+
|
31
|
+
# set to 'true' to allow .pyc and .pyo files without
|
32
|
+
# a source .py file to be detected as revisions in the
|
33
|
+
# versions/ directory
|
34
|
+
# sourceless = false
|
35
|
+
|
36
|
+
# version location specification; This defaults
|
37
|
+
# to ${script_location}/versions. When using multiple version
|
38
|
+
# directories, initial revisions must be specified with --version-path.
|
39
|
+
# The path separator used here should be the separator specified by "version_path_separator" below.
|
40
|
+
# version_locations = %(here)s/bar:%(here)s/bat:${script_location}/versions
|
41
|
+
|
42
|
+
# version path separator; As mentioned above, this is the character used to split
|
43
|
+
# version_locations. The default within new alembic.ini files is "os", which uses os.pathsep.
|
44
|
+
# If this key is omitted entirely, it falls back to the legacy behavior of splitting on spaces and/or commas.
|
45
|
+
# Valid values for version_path_separator are:
|
46
|
+
#
|
47
|
+
# version_path_separator = :
|
48
|
+
# version_path_separator = ;
|
49
|
+
# version_path_separator = space
|
50
|
+
# version_path_separator = newline
|
51
|
+
#
|
52
|
+
# Use os.pathsep. Default configuration used for new projects.
|
53
|
+
version_path_separator = os
|
54
|
+
|
55
|
+
# set to 'true' to search source files recursively
|
56
|
+
# in each "version_locations" directory
|
57
|
+
# new in Alembic version 1.10
|
58
|
+
# recursive_version_locations = false
|
59
|
+
|
60
|
+
# the output encoding used when revision files
|
61
|
+
# are written from script.py.mako
|
62
|
+
# output_encoding = utf-8
|
63
|
+
|
64
|
+
sqlalchemy.url = driver://user:pass@localhost/dbname
|
65
|
+
|
66
|
+
|
67
|
+
[post_write_hooks]
|
68
|
+
# post_write_hooks defines scripts or Python functions that are run
|
69
|
+
# on newly generated revision scripts. See the documentation for further
|
70
|
+
# detail and examples
|
71
|
+
|
72
|
+
# format using "black" - use the console_scripts runner, against the "black" entrypoint
|
73
|
+
# hooks = black
|
74
|
+
# black.type = console_scripts
|
75
|
+
# black.entrypoint = black
|
76
|
+
# black.options = -l 79 REVISION_SCRIPT_FILENAME
|
77
|
+
|
78
|
+
# lint with attempts to fix using "ruff" - use the exec runner, execute a binary
|
79
|
+
# hooks = ruff
|
80
|
+
# ruff.type = exec
|
81
|
+
# ruff.executable = %(here)s/.venv/bin/ruff
|
82
|
+
# ruff.options = check --fix REVISION_SCRIPT_FILENAME
|
83
|
+
|
84
|
+
# Logging configuration
|
85
|
+
[loggers]
|
86
|
+
keys = root,sqlalchemy,alembic
|
87
|
+
|
88
|
+
[handlers]
|
89
|
+
keys = console
|
90
|
+
|
91
|
+
[formatters]
|
92
|
+
keys = generic
|
93
|
+
|
94
|
+
[logger_root]
|
95
|
+
level = WARNING
|
96
|
+
handlers = console
|
97
|
+
qualname =
|
98
|
+
|
99
|
+
[logger_sqlalchemy]
|
100
|
+
level = WARNING
|
101
|
+
handlers =
|
102
|
+
qualname = sqlalchemy.engine
|
103
|
+
|
104
|
+
[logger_alembic]
|
105
|
+
level = INFO
|
106
|
+
handlers =
|
107
|
+
qualname = alembic
|
108
|
+
|
109
|
+
[handler_console]
|
110
|
+
class = StreamHandler
|
111
|
+
args = (sys.stderr,)
|
112
|
+
level = NOTSET
|
113
|
+
formatter = generic
|
114
|
+
|
115
|
+
[formatter_generic]
|
116
|
+
format = %(levelname)-5.5s [%(name)s] %(message)s
|
117
|
+
datefmt = %H:%M:%S
|
@@ -0,0 +1,28 @@
|
|
1
|
+
"""${message}
|
2
|
+
|
3
|
+
Revision ID: ${up_revision}
|
4
|
+
Revises: ${down_revision | comma,n}
|
5
|
+
Create Date: ${create_date}
|
6
|
+
|
7
|
+
"""
|
8
|
+
from typing import Sequence, Union
|
9
|
+
|
10
|
+
from alembic import op
|
11
|
+
import sqlalchemy as sa
|
12
|
+
${imports if imports else ""}
|
13
|
+
|
14
|
+
# revision identifiers, used by Alembic.
|
15
|
+
revision: str = ${repr(up_revision)}
|
16
|
+
down_revision: Union[str, None] = ${repr(down_revision)}
|
17
|
+
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
|
18
|
+
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
|
19
|
+
|
20
|
+
|
21
|
+
def upgrade() -> None:
|
22
|
+
"""Upgrade schema."""
|
23
|
+
${upgrades if upgrades else "pass"}
|
24
|
+
|
25
|
+
|
26
|
+
def downgrade() -> None:
|
27
|
+
"""Downgrade schema."""
|
28
|
+
${downgrades if downgrades else "pass"}
|
@@ -0,0 +1 @@
|
|
1
|
+
Generic single-database configuration.
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# A generic, single database configuration.
|
2
|
+
|
3
|
+
[alembic]
|
4
|
+
# path to migration scripts
|
5
|
+
# Use forward slashes (/) also on windows to provide an os agnostic path
|
6
|
+
script_location = ${script_location}
|
7
|
+
|
8
|
+
# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
|
9
|
+
# Uncomment the line below if you want the files to be prepended with date and time
|
10
|
+
# see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file
|
11
|
+
# for all available tokens
|
12
|
+
# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s
|
13
|
+
|
14
|
+
# sys.path path, will be prepended to sys.path if present.
|
15
|
+
# defaults to the current working directory.
|
16
|
+
prepend_sys_path = .
|
17
|
+
|
18
|
+
# timezone to use when rendering the date within the migration file
|
19
|
+
# as well as the filename.
|
20
|
+
# If specified, requires the python>=3.9 or backports.zoneinfo library and tzdata library.
|
21
|
+
# Any required deps can installed by adding `alembic[tz]` to the pip requirements
|
22
|
+
# string value is passed to ZoneInfo()
|
23
|
+
# leave blank for localtime
|
24
|
+
# timezone =
|
25
|
+
|
26
|
+
# max length of characters to apply to the "slug" field
|
27
|
+
# truncate_slug_length = 40
|
28
|
+
|
29
|
+
# set to 'true' to run the environment during
|
30
|
+
# the 'revision' command, regardless of autogenerate
|
31
|
+
# revision_environment = false
|
32
|
+
|
33
|
+
# set to 'true' to allow .pyc and .pyo files without
|
34
|
+
# a source .py file to be detected as revisions in the
|
35
|
+
# versions/ directory
|
36
|
+
# sourceless = false
|
37
|
+
|
38
|
+
# version location specification; This defaults
|
39
|
+
# to ${script_location}/versions. When using multiple version
|
40
|
+
# directories, initial revisions must be specified with --version-path.
|
41
|
+
# The path separator used here should be the separator specified by "version_path_separator" below.
|
42
|
+
# version_locations = %(here)s/bar:%(here)s/bat:${script_location}/versions
|
43
|
+
|
44
|
+
# version path separator; As mentioned above, this is the character used to split
|
45
|
+
# version_locations. The default within new alembic.ini files is "os", which uses os.pathsep.
|
46
|
+
# If this key is omitted entirely, it falls back to the legacy behavior of splitting on spaces and/or commas.
|
47
|
+
# Valid values for version_path_separator are:
|
48
|
+
#
|
49
|
+
# version_path_separator = :
|
50
|
+
# version_path_separator = ;
|
51
|
+
# version_path_separator = space
|
52
|
+
# version_path_separator = newline
|
53
|
+
#
|
54
|
+
# Use os.pathsep. Default configuration used for new projects.
|
55
|
+
version_path_separator = os
|
56
|
+
|
57
|
+
# set to 'true' to search source files recursively
|
58
|
+
# in each "version_locations" directory
|
59
|
+
# new in Alembic version 1.10
|
60
|
+
# recursive_version_locations = false
|
61
|
+
|
62
|
+
# the output encoding used when revision files
|
63
|
+
# are written from script.py.mako
|
64
|
+
# output_encoding = utf-8
|
65
|
+
|
66
|
+
sqlalchemy.url = driver://user:pass@localhost/dbname
|
67
|
+
|
68
|
+
|
69
|
+
[post_write_hooks]
|
70
|
+
# post_write_hooks defines scripts or Python functions that are run
|
71
|
+
# on newly generated revision scripts. See the documentation for further
|
72
|
+
# detail and examples
|
73
|
+
|
74
|
+
# format using "black" - use the console_scripts runner, against the "black" entrypoint
|
75
|
+
# hooks = black
|
76
|
+
# black.type = console_scripts
|
77
|
+
# black.entrypoint = black
|
78
|
+
# black.options = -l 79 REVISION_SCRIPT_FILENAME
|
79
|
+
|
80
|
+
# lint with attempts to fix using "ruff" - use the exec runner, execute a binary
|
81
|
+
# hooks = ruff
|
82
|
+
# ruff.type = exec
|
83
|
+
# ruff.executable = %(here)s/.venv/bin/ruff
|
84
|
+
# ruff.options = check --fix REVISION_SCRIPT_FILENAME
|
85
|
+
|
86
|
+
# Logging configuration
|
87
|
+
[loggers]
|
88
|
+
keys = root,sqlalchemy,alembic
|
89
|
+
|
90
|
+
[handlers]
|
91
|
+
keys = console
|
92
|
+
|
93
|
+
[formatters]
|
94
|
+
keys = generic
|
95
|
+
|
96
|
+
[logger_root]
|
97
|
+
level = WARNING
|
98
|
+
handlers = console
|
99
|
+
qualname =
|
100
|
+
|
101
|
+
[logger_sqlalchemy]
|
102
|
+
level = WARNING
|
103
|
+
handlers =
|
104
|
+
qualname = sqlalchemy.engine
|
105
|
+
|
106
|
+
[logger_alembic]
|
107
|
+
level = INFO
|
108
|
+
handlers =
|
109
|
+
qualname = alembic
|
110
|
+
|
111
|
+
[handler_console]
|
112
|
+
class = StreamHandler
|
113
|
+
args = (sys.stderr,)
|
114
|
+
level = NOTSET
|
115
|
+
formatter = generic
|
116
|
+
|
117
|
+
[formatter_generic]
|
118
|
+
format = %(levelname)-5.5s [%(name)s] %(message)s
|
119
|
+
datefmt = %H:%M:%S
|
@@ -0,0 +1,28 @@
|
|
1
|
+
"""${message}
|
2
|
+
|
3
|
+
Revision ID: ${up_revision}
|
4
|
+
Revises: ${down_revision | comma,n}
|
5
|
+
Create Date: ${create_date}
|
6
|
+
|
7
|
+
"""
|
8
|
+
from typing import Sequence, Union
|
9
|
+
|
10
|
+
from alembic import op
|
11
|
+
import sqlalchemy as sa
|
12
|
+
${imports if imports else ""}
|
13
|
+
|
14
|
+
# revision identifiers, used by Alembic.
|
15
|
+
revision: str = ${repr(up_revision)}
|
16
|
+
down_revision: Union[str, None] = ${repr(down_revision)}
|
17
|
+
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
|
18
|
+
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
|
19
|
+
|
20
|
+
|
21
|
+
def upgrade() -> None:
|
22
|
+
"""Upgrade schema."""
|
23
|
+
${upgrades if upgrades else "pass"}
|
24
|
+
|
25
|
+
|
26
|
+
def downgrade() -> None:
|
27
|
+
"""Downgrade schema."""
|
28
|
+
${downgrades if downgrades else "pass"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Rudimentary multi-database configuration.
|
2
|
+
|
3
|
+
Multi-DB isn't vastly different from generic. The primary difference is that it
|
4
|
+
will run the migrations N times (depending on how many databases you have
|
5
|
+
configured), providing one engine name and associated context for each run.
|
6
|
+
|
7
|
+
That engine name will then allow the migration to restrict what runs within it to
|
8
|
+
just the appropriate migrations for that engine. You can see this behavior within
|
9
|
+
the mako template.
|
10
|
+
|
11
|
+
In the provided configuration, you'll need to have `databases` provided in
|
12
|
+
alembic's config, and an `sqlalchemy.url` provided for each engine name.
|
@@ -0,0 +1,124 @@
|
|
1
|
+
# a multi-database configuration.
|
2
|
+
|
3
|
+
[alembic]
|
4
|
+
# path to migration scripts
|
5
|
+
# Use forward slashes (/) also on windows to provide an os agnostic path
|
6
|
+
script_location = ${script_location}
|
7
|
+
|
8
|
+
# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
|
9
|
+
# Uncomment the line below if you want the files to be prepended with date and time
|
10
|
+
# see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file
|
11
|
+
# for all available tokens
|
12
|
+
# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s
|
13
|
+
|
14
|
+
# sys.path path, will be prepended to sys.path if present.
|
15
|
+
# defaults to the current working directory.
|
16
|
+
prepend_sys_path = .
|
17
|
+
|
18
|
+
# timezone to use when rendering the date within the migration file
|
19
|
+
# as well as the filename.
|
20
|
+
# If specified, requires the python>=3.9 or backports.zoneinfo library and tzdata library.
|
21
|
+
# Any required deps can installed by adding `alembic[tz]` to the pip requirements
|
22
|
+
# string value is passed to ZoneInfo()
|
23
|
+
# leave blank for localtime
|
24
|
+
# timezone =
|
25
|
+
|
26
|
+
# max length of characters to apply to the "slug" field
|
27
|
+
# truncate_slug_length = 40
|
28
|
+
|
29
|
+
# set to 'true' to run the environment during
|
30
|
+
# the 'revision' command, regardless of autogenerate
|
31
|
+
# revision_environment = false
|
32
|
+
|
33
|
+
# set to 'true' to allow .pyc and .pyo files without
|
34
|
+
# a source .py file to be detected as revisions in the
|
35
|
+
# versions/ directory
|
36
|
+
# sourceless = false
|
37
|
+
|
38
|
+
# version location specification; This defaults
|
39
|
+
# to ${script_location}/versions. When using multiple version
|
40
|
+
# directories, initial revisions must be specified with --version-path.
|
41
|
+
# The path separator used here should be the separator specified by "version_path_separator" below.
|
42
|
+
# version_locations = %(here)s/bar:%(here)s/bat:${script_location}/versions
|
43
|
+
|
44
|
+
# version path separator; As mentioned above, this is the character used to split
|
45
|
+
# version_locations. The default within new alembic.ini files is "os", which uses os.pathsep.
|
46
|
+
# If this key is omitted entirely, it falls back to the legacy behavior of splitting on spaces and/or commas.
|
47
|
+
# Valid values for version_path_separator are:
|
48
|
+
#
|
49
|
+
# version_path_separator = :
|
50
|
+
# version_path_separator = ;
|
51
|
+
# version_path_separator = space
|
52
|
+
# version_path_separator = newline
|
53
|
+
#
|
54
|
+
# Use os.pathsep. Default configuration used for new projects.
|
55
|
+
version_path_separator = os
|
56
|
+
|
57
|
+
# set to 'true' to search source files recursively
|
58
|
+
# in each "version_locations" directory
|
59
|
+
# new in Alembic version 1.10
|
60
|
+
# recursive_version_locations = false
|
61
|
+
|
62
|
+
# the output encoding used when revision files
|
63
|
+
# are written from script.py.mako
|
64
|
+
# output_encoding = utf-8
|
65
|
+
|
66
|
+
databases = engine1, engine2
|
67
|
+
|
68
|
+
[engine1]
|
69
|
+
sqlalchemy.url = driver://user:pass@localhost/dbname
|
70
|
+
|
71
|
+
[engine2]
|
72
|
+
sqlalchemy.url = driver://user:pass@localhost/dbname2
|
73
|
+
|
74
|
+
[post_write_hooks]
|
75
|
+
# post_write_hooks defines scripts or Python functions that are run
|
76
|
+
# on newly generated revision scripts. See the documentation for further
|
77
|
+
# detail and examples
|
78
|
+
|
79
|
+
# format using "black" - use the console_scripts runner, against the "black" entrypoint
|
80
|
+
# hooks = black
|
81
|
+
# black.type = console_scripts
|
82
|
+
# black.entrypoint = black
|
83
|
+
# black.options = -l 79 REVISION_SCRIPT_FILENAME
|
84
|
+
|
85
|
+
# lint with attempts to fix using "ruff" - use the exec runner, execute a binary
|
86
|
+
# hooks = ruff
|
87
|
+
# ruff.type = exec
|
88
|
+
# ruff.executable = %(here)s/.venv/bin/ruff
|
89
|
+
# ruff.options = check --fix REVISION_SCRIPT_FILENAME
|
90
|
+
|
91
|
+
# Logging configuration
|
92
|
+
[loggers]
|
93
|
+
keys = root,sqlalchemy,alembic
|
94
|
+
|
95
|
+
[handlers]
|
96
|
+
keys = console
|
97
|
+
|
98
|
+
[formatters]
|
99
|
+
keys = generic
|
100
|
+
|
101
|
+
[logger_root]
|
102
|
+
level = WARNING
|
103
|
+
handlers = console
|
104
|
+
qualname =
|
105
|
+
|
106
|
+
[logger_sqlalchemy]
|
107
|
+
level = WARNING
|
108
|
+
handlers =
|
109
|
+
qualname = sqlalchemy.engine
|
110
|
+
|
111
|
+
[logger_alembic]
|
112
|
+
level = INFO
|
113
|
+
handlers =
|
114
|
+
qualname = alembic
|
115
|
+
|
116
|
+
[handler_console]
|
117
|
+
class = StreamHandler
|
118
|
+
args = (sys.stderr,)
|
119
|
+
level = NOTSET
|
120
|
+
formatter = generic
|
121
|
+
|
122
|
+
[formatter_generic]
|
123
|
+
format = %(levelname)-5.5s [%(name)s] %(message)s
|
124
|
+
datefmt = %H:%M:%S
|
@@ -0,0 +1,51 @@
|
|
1
|
+
<%!
|
2
|
+
import re
|
3
|
+
|
4
|
+
%>"""${message}
|
5
|
+
|
6
|
+
Revision ID: ${up_revision}
|
7
|
+
Revises: ${down_revision | comma,n}
|
8
|
+
Create Date: ${create_date}
|
9
|
+
|
10
|
+
"""
|
11
|
+
from typing import Sequence, Union
|
12
|
+
|
13
|
+
from alembic import op
|
14
|
+
import sqlalchemy as sa
|
15
|
+
${imports if imports else ""}
|
16
|
+
|
17
|
+
# revision identifiers, used by Alembic.
|
18
|
+
revision: str = ${repr(up_revision)}
|
19
|
+
down_revision: Union[str, None] = ${repr(down_revision)}
|
20
|
+
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
|
21
|
+
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
|
22
|
+
|
23
|
+
|
24
|
+
def upgrade(engine_name: str) -> None:
|
25
|
+
"""Upgrade schema."""
|
26
|
+
globals()["upgrade_%s" % engine_name]()
|
27
|
+
|
28
|
+
|
29
|
+
def downgrade(engine_name: str) -> None:
|
30
|
+
"""Downgrade schema."""
|
31
|
+
globals()["downgrade_%s" % engine_name]()
|
32
|
+
|
33
|
+
<%
|
34
|
+
db_names = config.get_main_option("databases")
|
35
|
+
%>
|
36
|
+
|
37
|
+
## generate an "upgrade_<xyz>() / downgrade_<xyz>()" function
|
38
|
+
## for each database name in the ini file.
|
39
|
+
|
40
|
+
% for db_name in re.split(r',\s*', db_names):
|
41
|
+
|
42
|
+
def upgrade_${db_name}() -> None:
|
43
|
+
"""Upgrade ${db_name} schema."""
|
44
|
+
${context.get("%s_upgrades" % db_name, "pass")}
|
45
|
+
|
46
|
+
|
47
|
+
def downgrade_${db_name}() -> None:
|
48
|
+
"""Downgrade ${db_name} schema."""
|
49
|
+
${context.get("%s_downgrades" % db_name, "pass")}
|
50
|
+
|
51
|
+
% endfor
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: alembic
|
3
|
-
Version: 1.15.
|
3
|
+
Version: 1.15.2
|
4
4
|
Summary: A database migration tool for SQLAlchemy.
|
5
5
|
Author-email: Mike Bayer <mike_mp@zzzcomputing.com>
|
6
6
|
License: MIT
|
@@ -32,6 +32,7 @@ Requires-Dist: Mako
|
|
32
32
|
Requires-Dist: typing-extensions>=4.12
|
33
33
|
Provides-Extra: tz
|
34
34
|
Requires-Dist: tzdata; extra == "tz"
|
35
|
+
Dynamic: license-file
|
35
36
|
|
36
37
|
Alembic is a database migrations tool written by the author
|
37
38
|
of `SQLAlchemy <http://www.sqlalchemy.org>`_. A migrations tool
|
@@ -1,4 +1,4 @@
|
|
1
|
-
alembic/__init__.py,sha256=
|
1
|
+
alembic/__init__.py,sha256=PDxLEkRWLmnGm-ZRbHkB5ttYSP5d2jSlESHuNdGYVtQ,63
|
2
2
|
alembic/__main__.py,sha256=373m7-TBh72JqrSMYviGrxCHZo-cnweM8AGF8A22PmY,78
|
3
3
|
alembic/command.py,sha256=HIRFQFUG_A9ZgLBC-MG2WmE_eX0QxvvX2Os-_eL2zBQ,22242
|
4
4
|
alembic/config.py,sha256=BZ7mwFRk2gq8GFNxxy9qvMUFx43YbDbQTC99OnjqiKY,22216
|
@@ -7,26 +7,26 @@ alembic/context.pyi,sha256=fdeFNTRc0bUgi7n2eZWVFh6NG-TzIv_0gAcapbfHnKY,31773
|
|
7
7
|
alembic/environment.py,sha256=MM5lPayGT04H3aeng1H7GQ8HEAs3VGX5yy6mDLCPLT4,43
|
8
8
|
alembic/migration.py,sha256=MV6Fju6rZtn2fTREKzXrCZM6aIBGII4OMZFix0X-GLs,41
|
9
9
|
alembic/op.py,sha256=flHtcsVqOD-ZgZKK2pv-CJ5Cwh-KJ7puMUNXzishxLw,167
|
10
|
-
alembic/op.pyi,sha256=
|
10
|
+
alembic/op.pyi,sha256=_ZlgVwkkhey7kVGgnydFCLvvvFQo2uEofbyNpRXKupA,50180
|
11
11
|
alembic/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
12
12
|
alembic/autogenerate/__init__.py,sha256=ntmUTXhjLm4_zmqIwyVaECdpPDn6_u1yM9vYk6-553E,543
|
13
13
|
alembic/autogenerate/api.py,sha256=L4qkapSJO1Ypymx8HsjLl0vFFt202agwMYsQbIe6ZtI,22219
|
14
14
|
alembic/autogenerate/compare.py,sha256=FKmfogZOLXp4EIx9eQ-q_DzlnI4-jZYqyxw2yOw_84A,44341
|
15
|
-
alembic/autogenerate/render.py,sha256=
|
15
|
+
alembic/autogenerate/render.py,sha256=VFk0RZZ4Db_T2FQdtt2lzuHuE3x6r0VyWgzc_dnimgI,35877
|
16
16
|
alembic/autogenerate/rewriter.py,sha256=uZWRkTYJoncoEJ5WY1QBRiozjyChqZDJPy4LtcRibjM,7846
|
17
17
|
alembic/ddl/__init__.py,sha256=Df8fy4Vn_abP8B7q3x8gyFwEwnLw6hs2Ljt_bV3EZWE,152
|
18
18
|
alembic/ddl/_autogen.py,sha256=Blv2RrHNyF4cE6znCQXNXG5T9aO-YmiwD4Fz-qfoaWA,9275
|
19
|
-
alembic/ddl/base.py,sha256=
|
20
|
-
alembic/ddl/impl.py,sha256=
|
19
|
+
alembic/ddl/base.py,sha256=XlT5XEE6mtn09jfJ3khHmIM8iECmM8rlJEnTQa5vU60,9948
|
20
|
+
alembic/ddl/impl.py,sha256=SYQg-Sz7OGOJi3h0VAC0GIEiJp7TZwUUN2VGshmj0uE,30066
|
21
21
|
alembic/ddl/mssql.py,sha256=ydvgBSaftKYjaBaMyqius66Ta4CICQSj79Og3Ed2atY,14219
|
22
22
|
alembic/ddl/mysql.py,sha256=9OOAmtg4GpEqWSbATT6FCq0xLnU8PMjr0VlRB171-EI,17301
|
23
23
|
alembic/ddl/oracle.py,sha256=669YlkcZihlXFbnXhH2krdrvDry8q5pcUGfoqkg_R6Y,6243
|
24
24
|
alembic/ddl/postgresql.py,sha256=D4oCA2xCrKV-82aAEmXgEe-llyDtL4xc9_tAZgznkuU,29931
|
25
25
|
alembic/ddl/sqlite.py,sha256=9p9dlXbGMZACqeFnSuhm7eSapFDGJNd6WhBhZrdpqFg,7995
|
26
26
|
alembic/operations/__init__.py,sha256=e0KQSZAgLpTWvyvreB7DWg7RJV_MWSOPVDgCqsd2FzY,318
|
27
|
-
alembic/operations/base.py,sha256=
|
27
|
+
alembic/operations/base.py,sha256=xG-pYE3Aw0kU0_7cxSiNpv_U9dSrWy4E5aOsAApOURs,74516
|
28
28
|
alembic/operations/batch.py,sha256=1UmCFcsFWObinQWFRWoGZkjynl54HKpldbPs67aR4wg,26923
|
29
|
-
alembic/operations/ops.py,sha256=
|
29
|
+
alembic/operations/ops.py,sha256=Xjas55xKsOrT_BMLbiF_MpK2bhUMy1nCrI69--Gw1Bk,94983
|
30
30
|
alembic/operations/schemaobj.py,sha256=Wp-bBe4a8lXPTvIHJttBY0ejtpVR5Jvtb2kI-U2PztQ,9468
|
31
31
|
alembic/operations/toimpl.py,sha256=DhydxHxPlPejzFPHsN1VR2tHINUdlJw3eKOjjmJCyu0,7114
|
32
32
|
alembic/runtime/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -36,9 +36,18 @@ alembic/script/__init__.py,sha256=lSj06O391Iy5avWAiq8SPs6N8RBgxkSPjP8wpXcNDGg,10
|
|
36
36
|
alembic/script/base.py,sha256=XLNpdsLnBBSz4ZKMFUArFUdtL1HcjtuUDHNbA-5VlZA,37809
|
37
37
|
alembic/script/revision.py,sha256=NTu-eu5Y78u4NoVXpT0alpD2oL40SGATA2sEMEf1el4,62306
|
38
38
|
alembic/script/write_hooks.py,sha256=NGB6NGgfdf7HK6XNNpSKqUCfzxazj-NRUePgFx7MJSM,5036
|
39
|
+
alembic/templates/async/README,sha256=ISVtAOvqvKk_5ThM5ioJE-lMkvf9IbknFUFVU_vPma4,58
|
40
|
+
alembic/templates/async/alembic.ini.mako,sha256=mt-JvqniFqUGyVFBcB6dowg0bhQBTDDZfqEdGQJMJF4,3664
|
39
41
|
alembic/templates/async/env.py,sha256=zbOCf3Y7w2lg92hxSwmG1MM_7y56i_oRH4AKp0pQBYo,2389
|
42
|
+
alembic/templates/async/script.py.mako,sha256=3qBrHBf7F7ChKDUIdiNItiSXrDpgQdM7sR0YKzpaC50,689
|
43
|
+
alembic/templates/generic/README,sha256=MVlc9TYmr57RbhXET6QxgyCcwWP7w-vLkEsirENqiIQ,38
|
44
|
+
alembic/templates/generic/alembic.ini.mako,sha256=5wBSGyn3C9RsfM3-ztwpHo2JPOnXT-6xwksyZ7nzPx0,3772
|
40
45
|
alembic/templates/generic/env.py,sha256=TLRWOVW3Xpt_Tpf8JFzlnoPn_qoUu8UV77Y4o9XD6yI,2103
|
46
|
+
alembic/templates/generic/script.py.mako,sha256=3qBrHBf7F7ChKDUIdiNItiSXrDpgQdM7sR0YKzpaC50,689
|
47
|
+
alembic/templates/multidb/README,sha256=dWLDhnBgphA4Nzb7sNlMfCS3_06YqVbHhz-9O5JNqyI,606
|
48
|
+
alembic/templates/multidb/alembic.ini.mako,sha256=10BzgDYUhrnMn4_hD1l-XH52TqlPEkQBlYs19zE3iyk,3866
|
41
49
|
alembic/templates/multidb/env.py,sha256=6zNjnW8mXGUk7erTsAvrfhvqoczJ-gagjVq1Ypg2YIQ,4230
|
50
|
+
alembic/templates/multidb/script.py.mako,sha256=d0Pl1Z57DASni61GtdV1jTiSJfIx6IwIjEQx2_DeHIU,1220
|
42
51
|
alembic/testing/__init__.py,sha256=kOxOh5nwmui9d-_CCq9WA4Udwy7ITjm453w74CTLZDo,1159
|
43
52
|
alembic/testing/assertions.py,sha256=_zaiHj0RcmJs0u1EjrfELWUSi8aUu6xKvzdZ6hDuYUc,5196
|
44
53
|
alembic/testing/env.py,sha256=IkQnQmp6g5U82iZHkcndr7MndO3_UBn2TF_40TZ2ua0,10537
|
@@ -66,9 +75,9 @@ alembic/util/langhelpers.py,sha256=LpOcovnhMnP45kTt8zNJ4BHpyQrlF40OL6yDXjqKtsE,1
|
|
66
75
|
alembic/util/messaging.py,sha256=aLF6xbRiOCOEW1UY5vA9AAlfkGeNLqPPGSs-3c8-bfc,3166
|
67
76
|
alembic/util/pyfiles.py,sha256=zltVdcwEJJCPS2gHsQvkHkQakuF6wXiZ6zfwHbGNT0g,3489
|
68
77
|
alembic/util/sqla_compat.py,sha256=SWAL4hJck4XLnUpe-oI3AGiH8w9kgDBe1_oakCfdT_Q,14785
|
69
|
-
alembic-1.15.
|
70
|
-
alembic-1.15.
|
71
|
-
alembic-1.15.
|
72
|
-
alembic-1.15.
|
73
|
-
alembic-1.15.
|
74
|
-
alembic-1.15.
|
78
|
+
alembic-1.15.2.dist-info/licenses/LICENSE,sha256=NeqcNBmyYfrxvkSMT0fZJVKBv2s2tf_qVQUiJ9S6VN4,1059
|
79
|
+
alembic-1.15.2.dist-info/METADATA,sha256=cVL7zyIqMo0m8XWloUHPxkUzUS9jiNq12BMZWm8igfo,7259
|
80
|
+
alembic-1.15.2.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
81
|
+
alembic-1.15.2.dist-info/entry_points.txt,sha256=aykM30soxwGN0pB7etLc1q0cHJbL9dy46RnK9VX4LLw,48
|
82
|
+
alembic-1.15.2.dist-info/top_level.txt,sha256=FwKWd5VsPFC8iQjpu1u9Cn-JnK3-V1RhUCmWqz1cl-s,8
|
83
|
+
alembic-1.15.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|