alembic 1.13.3__py3-none-any.whl → 1.14.0__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/ddl/base.py +9 -9
- alembic/ddl/impl.py +39 -2
- alembic/runtime/migration.py +12 -17
- alembic/templates/async/alembic.ini.mako +2 -2
- alembic/templates/generic/alembic.ini.mako +2 -2
- alembic/templates/multidb/alembic.ini.mako +2 -2
- alembic/testing/env.py +4 -4
- {alembic-1.13.3.dist-info → alembic-1.14.0.dist-info}/METADATA +1 -1
- {alembic-1.13.3.dist-info → alembic-1.14.0.dist-info}/RECORD +14 -14
- {alembic-1.13.3.dist-info → alembic-1.14.0.dist-info}/WHEEL +1 -1
- {alembic-1.13.3.dist-info → alembic-1.14.0.dist-info}/LICENSE +0 -0
- {alembic-1.13.3.dist-info → alembic-1.14.0.dist-info}/entry_points.txt +0 -0
- {alembic-1.13.3.dist-info → alembic-1.14.0.dist-info}/top_level.txt +0 -0
alembic/__init__.py
CHANGED
alembic/ddl/base.py
CHANGED
@@ -175,7 +175,7 @@ class ColumnComment(AlterColumn):
|
|
175
175
|
self.comment = comment
|
176
176
|
|
177
177
|
|
178
|
-
@compiles(RenameTable)
|
178
|
+
@compiles(RenameTable)
|
179
179
|
def visit_rename_table(
|
180
180
|
element: RenameTable, compiler: DDLCompiler, **kw
|
181
181
|
) -> str:
|
@@ -185,7 +185,7 @@ def visit_rename_table(
|
|
185
185
|
)
|
186
186
|
|
187
187
|
|
188
|
-
@compiles(AddColumn)
|
188
|
+
@compiles(AddColumn)
|
189
189
|
def visit_add_column(element: AddColumn, compiler: DDLCompiler, **kw) -> str:
|
190
190
|
return "%s %s" % (
|
191
191
|
alter_table(compiler, element.table_name, element.schema),
|
@@ -193,7 +193,7 @@ def visit_add_column(element: AddColumn, compiler: DDLCompiler, **kw) -> str:
|
|
193
193
|
)
|
194
194
|
|
195
195
|
|
196
|
-
@compiles(DropColumn)
|
196
|
+
@compiles(DropColumn)
|
197
197
|
def visit_drop_column(element: DropColumn, compiler: DDLCompiler, **kw) -> str:
|
198
198
|
return "%s %s" % (
|
199
199
|
alter_table(compiler, element.table_name, element.schema),
|
@@ -201,7 +201,7 @@ def visit_drop_column(element: DropColumn, compiler: DDLCompiler, **kw) -> str:
|
|
201
201
|
)
|
202
202
|
|
203
203
|
|
204
|
-
@compiles(ColumnNullable)
|
204
|
+
@compiles(ColumnNullable)
|
205
205
|
def visit_column_nullable(
|
206
206
|
element: ColumnNullable, compiler: DDLCompiler, **kw
|
207
207
|
) -> str:
|
@@ -212,7 +212,7 @@ def visit_column_nullable(
|
|
212
212
|
)
|
213
213
|
|
214
214
|
|
215
|
-
@compiles(ColumnType)
|
215
|
+
@compiles(ColumnType)
|
216
216
|
def visit_column_type(element: ColumnType, compiler: DDLCompiler, **kw) -> str:
|
217
217
|
return "%s %s %s" % (
|
218
218
|
alter_table(compiler, element.table_name, element.schema),
|
@@ -221,7 +221,7 @@ def visit_column_type(element: ColumnType, compiler: DDLCompiler, **kw) -> str:
|
|
221
221
|
)
|
222
222
|
|
223
223
|
|
224
|
-
@compiles(ColumnName)
|
224
|
+
@compiles(ColumnName)
|
225
225
|
def visit_column_name(element: ColumnName, compiler: DDLCompiler, **kw) -> str:
|
226
226
|
return "%s RENAME %s TO %s" % (
|
227
227
|
alter_table(compiler, element.table_name, element.schema),
|
@@ -230,7 +230,7 @@ def visit_column_name(element: ColumnName, compiler: DDLCompiler, **kw) -> str:
|
|
230
230
|
)
|
231
231
|
|
232
232
|
|
233
|
-
@compiles(ColumnDefault)
|
233
|
+
@compiles(ColumnDefault)
|
234
234
|
def visit_column_default(
|
235
235
|
element: ColumnDefault, compiler: DDLCompiler, **kw
|
236
236
|
) -> str:
|
@@ -245,7 +245,7 @@ def visit_column_default(
|
|
245
245
|
)
|
246
246
|
|
247
247
|
|
248
|
-
@compiles(ComputedColumnDefault)
|
248
|
+
@compiles(ComputedColumnDefault)
|
249
249
|
def visit_computed_column(
|
250
250
|
element: ComputedColumnDefault, compiler: DDLCompiler, **kw
|
251
251
|
):
|
@@ -255,7 +255,7 @@ def visit_computed_column(
|
|
255
255
|
)
|
256
256
|
|
257
257
|
|
258
|
-
@compiles(IdentityColumnDefault)
|
258
|
+
@compiles(IdentityColumnDefault)
|
259
259
|
def visit_identity_column(
|
260
260
|
element: IdentityColumnDefault, compiler: DDLCompiler, **kw
|
261
261
|
):
|
alembic/ddl/impl.py
CHANGED
@@ -21,7 +21,12 @@ from typing import TYPE_CHECKING
|
|
21
21
|
from typing import Union
|
22
22
|
|
23
23
|
from sqlalchemy import cast
|
24
|
+
from sqlalchemy import Column
|
25
|
+
from sqlalchemy import MetaData
|
26
|
+
from sqlalchemy import PrimaryKeyConstraint
|
24
27
|
from sqlalchemy import schema
|
28
|
+
from sqlalchemy import String
|
29
|
+
from sqlalchemy import Table
|
25
30
|
from sqlalchemy import text
|
26
31
|
|
27
32
|
from . import _autogen
|
@@ -43,11 +48,9 @@ if TYPE_CHECKING:
|
|
43
48
|
from sqlalchemy.sql import Executable
|
44
49
|
from sqlalchemy.sql.elements import ColumnElement
|
45
50
|
from sqlalchemy.sql.elements import quoted_name
|
46
|
-
from sqlalchemy.sql.schema import Column
|
47
51
|
from sqlalchemy.sql.schema import Constraint
|
48
52
|
from sqlalchemy.sql.schema import ForeignKeyConstraint
|
49
53
|
from sqlalchemy.sql.schema import Index
|
50
|
-
from sqlalchemy.sql.schema import Table
|
51
54
|
from sqlalchemy.sql.schema import UniqueConstraint
|
52
55
|
from sqlalchemy.sql.selectable import TableClause
|
53
56
|
from sqlalchemy.sql.type_api import TypeEngine
|
@@ -136,6 +139,40 @@ class DefaultImpl(metaclass=ImplMeta):
|
|
136
139
|
self.output_buffer.write(text + "\n\n")
|
137
140
|
self.output_buffer.flush()
|
138
141
|
|
142
|
+
def version_table_impl(
|
143
|
+
self,
|
144
|
+
*,
|
145
|
+
version_table: str,
|
146
|
+
version_table_schema: Optional[str],
|
147
|
+
version_table_pk: bool,
|
148
|
+
**kw: Any,
|
149
|
+
) -> Table:
|
150
|
+
"""Generate a :class:`.Table` object which will be used as the
|
151
|
+
structure for the Alembic version table.
|
152
|
+
|
153
|
+
Third party dialects may override this hook to provide an alternate
|
154
|
+
structure for this :class:`.Table`; requirements are only that it
|
155
|
+
be named based on the ``version_table`` parameter and contains
|
156
|
+
at least a single string-holding column named ``version_num``.
|
157
|
+
|
158
|
+
.. versionadded:: 1.14
|
159
|
+
|
160
|
+
"""
|
161
|
+
vt = Table(
|
162
|
+
version_table,
|
163
|
+
MetaData(),
|
164
|
+
Column("version_num", String(32), nullable=False),
|
165
|
+
schema=version_table_schema,
|
166
|
+
)
|
167
|
+
if version_table_pk:
|
168
|
+
vt.append_constraint(
|
169
|
+
PrimaryKeyConstraint(
|
170
|
+
"version_num", name=f"{version_table}_pkc"
|
171
|
+
)
|
172
|
+
)
|
173
|
+
|
174
|
+
return vt
|
175
|
+
|
139
176
|
def requires_recreate_in_batch(
|
140
177
|
self, batch_op: BatchOperationsImpl
|
141
178
|
) -> bool:
|
alembic/runtime/migration.py
CHANGED
@@ -24,10 +24,6 @@ from typing import Union
|
|
24
24
|
|
25
25
|
from sqlalchemy import Column
|
26
26
|
from sqlalchemy import literal_column
|
27
|
-
from sqlalchemy import MetaData
|
28
|
-
from sqlalchemy import PrimaryKeyConstraint
|
29
|
-
from sqlalchemy import String
|
30
|
-
from sqlalchemy import Table
|
31
27
|
from sqlalchemy.engine import Engine
|
32
28
|
from sqlalchemy.engine import url as sqla_url
|
33
29
|
from sqlalchemy.engine.strategies import MockEngineStrategy
|
@@ -36,6 +32,7 @@ from .. import ddl
|
|
36
32
|
from .. import util
|
37
33
|
from ..util import sqla_compat
|
38
34
|
from ..util.compat import EncodedIO
|
35
|
+
from ..util.sqla_compat import _select
|
39
36
|
|
40
37
|
if TYPE_CHECKING:
|
41
38
|
from sqlalchemy.engine import Dialect
|
@@ -190,18 +187,6 @@ class MigrationContext:
|
|
190
187
|
self.version_table_schema = version_table_schema = opts.get(
|
191
188
|
"version_table_schema", None
|
192
189
|
)
|
193
|
-
self._version = Table(
|
194
|
-
version_table,
|
195
|
-
MetaData(),
|
196
|
-
Column("version_num", String(32), nullable=False),
|
197
|
-
schema=version_table_schema,
|
198
|
-
)
|
199
|
-
if opts.get("version_table_pk", True):
|
200
|
-
self._version.append_constraint(
|
201
|
-
PrimaryKeyConstraint(
|
202
|
-
"version_num", name="%s_pkc" % version_table
|
203
|
-
)
|
204
|
-
)
|
205
190
|
|
206
191
|
self._start_from_rev: Optional[str] = opts.get("starting_rev")
|
207
192
|
self.impl = ddl.DefaultImpl.get_by_dialect(dialect)(
|
@@ -212,6 +197,13 @@ class MigrationContext:
|
|
212
197
|
self.output_buffer,
|
213
198
|
opts,
|
214
199
|
)
|
200
|
+
|
201
|
+
self._version = self.impl.version_table_impl(
|
202
|
+
version_table=version_table,
|
203
|
+
version_table_schema=version_table_schema,
|
204
|
+
version_table_pk=opts.get("version_table_pk", True),
|
205
|
+
)
|
206
|
+
|
215
207
|
log.info("Context impl %s.", self.impl.__class__.__name__)
|
216
208
|
if self.as_sql:
|
217
209
|
log.info("Generating static SQL")
|
@@ -540,7 +532,10 @@ class MigrationContext:
|
|
540
532
|
return ()
|
541
533
|
assert self.connection is not None
|
542
534
|
return tuple(
|
543
|
-
row[0]
|
535
|
+
row[0]
|
536
|
+
for row in self.connection.execute(
|
537
|
+
_select(self._version.c.version_num)
|
538
|
+
)
|
544
539
|
)
|
545
540
|
|
546
541
|
def _ensure_version_table(self, purge: bool = False) -> None:
|
@@ -97,12 +97,12 @@ keys = console
|
|
97
97
|
keys = generic
|
98
98
|
|
99
99
|
[logger_root]
|
100
|
-
level =
|
100
|
+
level = WARNING
|
101
101
|
handlers = console
|
102
102
|
qualname =
|
103
103
|
|
104
104
|
[logger_sqlalchemy]
|
105
|
-
level =
|
105
|
+
level = WARNING
|
106
106
|
handlers =
|
107
107
|
qualname = sqlalchemy.engine
|
108
108
|
|
alembic/testing/env.py
CHANGED
@@ -118,7 +118,7 @@ keys = root,sqlalchemy
|
|
118
118
|
keys = console
|
119
119
|
|
120
120
|
[logger_root]
|
121
|
-
level =
|
121
|
+
level = WARNING
|
122
122
|
handlers = console
|
123
123
|
qualname =
|
124
124
|
|
@@ -171,7 +171,7 @@ keys = root
|
|
171
171
|
keys = console
|
172
172
|
|
173
173
|
[logger_root]
|
174
|
-
level =
|
174
|
+
level = WARNING
|
175
175
|
handlers = console
|
176
176
|
qualname =
|
177
177
|
|
@@ -216,7 +216,7 @@ keys = root
|
|
216
216
|
keys = console
|
217
217
|
|
218
218
|
[logger_root]
|
219
|
-
level =
|
219
|
+
level = WARNING
|
220
220
|
handlers = console
|
221
221
|
qualname =
|
222
222
|
|
@@ -497,7 +497,7 @@ keys = root
|
|
497
497
|
keys = console
|
498
498
|
|
499
499
|
[logger_root]
|
500
|
-
level =
|
500
|
+
level = WARNING
|
501
501
|
handlers = console
|
502
502
|
qualname =
|
503
503
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
alembic/__init__.py,sha256=
|
1
|
+
alembic/__init__.py,sha256=qw_qYmTjOKiGcs--x0c6kjZo70tQTR5m8_lqF98Qr_0,63
|
2
2
|
alembic/__main__.py,sha256=373m7-TBh72JqrSMYviGrxCHZo-cnweM8AGF8A22PmY,78
|
3
3
|
alembic/command.py,sha256=2tkKrIoEgPfXrGgvMRGrUXH4l-7z466DOxd7Q2XOfL8,22169
|
4
4
|
alembic/config.py,sha256=BZ7mwFRk2gq8GFNxxy9qvMUFx43YbDbQTC99OnjqiKY,22216
|
@@ -16,8 +16,8 @@ alembic/autogenerate/render.py,sha256=YB3C90rq7XDhjTia9GAnK6yfnVVzCROziZrbArmG9S
|
|
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=gazpvtk_6XURcsa0libwcaIquL5HwJDP1ZWKJ6P7x0I,9788
|
20
|
+
alembic/ddl/impl.py,sha256=7-oxMb7KeycaK96x-kXw4mR6NSE1tmN0UEZIZrPcuhY,30195
|
21
21
|
alembic/ddl/mssql.py,sha256=ydvgBSaftKYjaBaMyqius66Ta4CICQSj79Og3Ed2atY,14219
|
22
22
|
alembic/ddl/mysql.py,sha256=kXOGYmpnL_9WL3ijXNsG4aAwy3m1HWJOoLZSePzmJF0,17316
|
23
23
|
alembic/ddl/oracle.py,sha256=669YlkcZihlXFbnXhH2krdrvDry8q5pcUGfoqkg_R6Y,6243
|
@@ -31,26 +31,26 @@ alembic/operations/schemaobj.py,sha256=Wp-bBe4a8lXPTvIHJttBY0ejtpVR5Jvtb2kI-U2Pz
|
|
31
31
|
alembic/operations/toimpl.py,sha256=Fx-UKcq6S8pVtsEwPFjTKtEcAVKjfptn-BfpE1k3_ck,7517
|
32
32
|
alembic/runtime/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
33
33
|
alembic/runtime/environment.py,sha256=SkYB_am1h3FSG8IsExAQxGP_7WwzOVigqjlO747Aokc,41497
|
34
|
-
alembic/runtime/migration.py,sha256=
|
34
|
+
alembic/runtime/migration.py,sha256=9GZ_bYZ6yMF7DUD1hgZdmB0YqvcdcNBBfxFaXKHeQoM,49857
|
35
35
|
alembic/script/__init__.py,sha256=lSj06O391Iy5avWAiq8SPs6N8RBgxkSPjP8wpXcNDGg,100
|
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
39
|
alembic/templates/async/README,sha256=ISVtAOvqvKk_5ThM5ioJE-lMkvf9IbknFUFVU_vPma4,58
|
40
|
-
alembic/templates/async/alembic.ini.mako,sha256=
|
40
|
+
alembic/templates/async/alembic.ini.mako,sha256=lw_6ie1tMbYGpbvE7MnzJvx101RbSTh9uu4t9cvDpug,3638
|
41
41
|
alembic/templates/async/env.py,sha256=zbOCf3Y7w2lg92hxSwmG1MM_7y56i_oRH4AKp0pQBYo,2389
|
42
42
|
alembic/templates/async/script.py.mako,sha256=MEqL-2qATlST9TAOeYgscMn1uy6HUS9NFvDgl93dMj8,635
|
43
43
|
alembic/templates/generic/README,sha256=MVlc9TYmr57RbhXET6QxgyCcwWP7w-vLkEsirENqiIQ,38
|
44
|
-
alembic/templates/generic/alembic.ini.mako,sha256=
|
44
|
+
alembic/templates/generic/alembic.ini.mako,sha256=YcwTOEoiZr663Gkt6twCjmaqZao0n6xjRl0B5prK79s,3746
|
45
45
|
alembic/templates/generic/env.py,sha256=TLRWOVW3Xpt_Tpf8JFzlnoPn_qoUu8UV77Y4o9XD6yI,2103
|
46
46
|
alembic/templates/generic/script.py.mako,sha256=MEqL-2qATlST9TAOeYgscMn1uy6HUS9NFvDgl93dMj8,635
|
47
47
|
alembic/templates/multidb/README,sha256=dWLDhnBgphA4Nzb7sNlMfCS3_06YqVbHhz-9O5JNqyI,606
|
48
|
-
alembic/templates/multidb/alembic.ini.mako,sha256=
|
48
|
+
alembic/templates/multidb/alembic.ini.mako,sha256=AW1OGb-QezxBY5mynSWW7b1lGKnh9sVPImfGgfXf2EM,3840
|
49
49
|
alembic/templates/multidb/env.py,sha256=6zNjnW8mXGUk7erTsAvrfhvqoczJ-gagjVq1Ypg2YIQ,4230
|
50
50
|
alembic/templates/multidb/script.py.mako,sha256=N06nMtNSwHkgl0EBXDyMt8njp9tlOesR583gfq21nbY,1090
|
51
51
|
alembic/testing/__init__.py,sha256=kOxOh5nwmui9d-_CCq9WA4Udwy7ITjm453w74CTLZDo,1159
|
52
52
|
alembic/testing/assertions.py,sha256=ScUb1sVopIl70BirfHUJDvwswC70Q93CiIWwkiZbhHg,5207
|
53
|
-
alembic/testing/env.py,sha256=
|
53
|
+
alembic/testing/env.py,sha256=giHWVLhHkfNWrPEfrAqhpMOLL6FgWoBCVAzBVrVbSSA,10766
|
54
54
|
alembic/testing/fixtures.py,sha256=nBntOynOmVCFc7IYiN3DIQ3TBNTfiGCvL_1-FyCry8o,9462
|
55
55
|
alembic/testing/requirements.py,sha256=dKeAO1l5TwBqXarJN-IPORlCqCJv-41Dj6oXoEikxHQ,5133
|
56
56
|
alembic/testing/schemacompare.py,sha256=N5UqSNCOJetIKC4vKhpYzQEpj08XkdgIoqBmEPQ3tlc,4838
|
@@ -75,9 +75,9 @@ alembic/util/langhelpers.py,sha256=LpOcovnhMnP45kTt8zNJ4BHpyQrlF40OL6yDXjqKtsE,1
|
|
75
75
|
alembic/util/messaging.py,sha256=BxAHiJsYHBPb2m8zv4yaueSRAlVuYXWkRCeN02JXhqw,3250
|
76
76
|
alembic/util/pyfiles.py,sha256=zltVdcwEJJCPS2gHsQvkHkQakuF6wXiZ6zfwHbGNT0g,3489
|
77
77
|
alembic/util/sqla_compat.py,sha256=XMfZaLdbVbJoniNUyI3RUUXu4gCWljjVBbJ7db6vCgc,19526
|
78
|
-
alembic-1.
|
79
|
-
alembic-1.
|
80
|
-
alembic-1.
|
81
|
-
alembic-1.
|
82
|
-
alembic-1.
|
83
|
-
alembic-1.
|
78
|
+
alembic-1.14.0.dist-info/LICENSE,sha256=zhnnuit3ylhLgqZ5KFbhOOswsxHIlrB2wJpAXuRfvuk,1059
|
79
|
+
alembic-1.14.0.dist-info/METADATA,sha256=5hNrxl9umF2WKbNL-MxyMUEZem8-OxRa49Qz9w7jqzo,7390
|
80
|
+
alembic-1.14.0.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
81
|
+
alembic-1.14.0.dist-info/entry_points.txt,sha256=aykM30soxwGN0pB7etLc1q0cHJbL9dy46RnK9VX4LLw,48
|
82
|
+
alembic-1.14.0.dist-info/top_level.txt,sha256=FwKWd5VsPFC8iQjpu1u9Cn-JnK3-V1RhUCmWqz1cl-s,8
|
83
|
+
alembic-1.14.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|