peewee-migrate 2.2.0__tar.gz → 2.3.0__tar.gz
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.
- {peewee_migrate-2.2.0 → peewee_migrate-2.3.0}/PKG-INFO +1 -1
- {peewee_migrate-2.2.0 → peewee_migrate-2.3.0}/peewee_migrate/migrator.py +14 -10
- {peewee_migrate-2.2.0 → peewee_migrate-2.3.0}/peewee_migrate/router.py +1 -1
- {peewee_migrate-2.2.0 → peewee_migrate-2.3.0}/peewee_migrate/template.py +1 -1
- {peewee_migrate-2.2.0 → peewee_migrate-2.3.0}/pyproject.toml +2 -2
- {peewee_migrate-2.2.0 → peewee_migrate-2.3.0}/pyproject.toml.orig +2 -2
- {peewee_migrate-2.2.0 → peewee_migrate-2.3.0}/README.rst +0 -0
- {peewee_migrate-2.2.0 → peewee_migrate-2.3.0}/peewee_migrate/__init__.py +0 -0
- {peewee_migrate-2.2.0 → peewee_migrate-2.3.0}/peewee_migrate/__main__.py +0 -0
- {peewee_migrate-2.2.0 → peewee_migrate-2.3.0}/peewee_migrate/auto.py +0 -0
- {peewee_migrate-2.2.0 → peewee_migrate-2.3.0}/peewee_migrate/cli.py +0 -0
- {peewee_migrate-2.2.0 → peewee_migrate-2.3.0}/peewee_migrate/logs.py +0 -0
- {peewee_migrate-2.2.0 → peewee_migrate-2.3.0}/peewee_migrate/models.py +0 -0
- {peewee_migrate-2.2.0 → peewee_migrate-2.3.0}/peewee_migrate/py.typed +0 -0
- {peewee_migrate-2.2.0 → peewee_migrate-2.3.0}/peewee_migrate/types.py +0 -0
- {peewee_migrate-2.2.0 → peewee_migrate-2.3.0}/peewee_migrate/utils.py +0 -0
|
@@ -68,14 +68,15 @@ class Migrator:
|
|
|
68
68
|
|
|
69
69
|
def __call__(self):
|
|
70
70
|
"""Run operations."""
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
71
|
+
with self.__migrator__.migration_context():
|
|
72
|
+
for op in self.__ops__:
|
|
73
|
+
if isinstance(op, Operation):
|
|
74
|
+
logger.info("%s %s", op.fn.__name__, op.args)
|
|
75
|
+
op.run()
|
|
76
|
+
else:
|
|
77
|
+
logger.info("Run %s", op.__name__)
|
|
78
|
+
op()
|
|
79
|
+
self.__ops__ = []
|
|
79
80
|
|
|
80
81
|
def __iter__(self):
|
|
81
82
|
"""Iterate over models."""
|
|
@@ -146,10 +147,13 @@ class Migrator:
|
|
|
146
147
|
self.__migrator__.drop_table(meta.table_name, cascade=cascade, schema=meta.schema)
|
|
147
148
|
)
|
|
148
149
|
|
|
149
|
-
def add_fields(
|
|
150
|
+
def add_fields(
|
|
151
|
+
self, model: str | TModelType, *, allow_not_null: bool = False, **fields: pw.Field
|
|
152
|
+
) -> TModelType:
|
|
150
153
|
"""Change fields.
|
|
151
154
|
|
|
152
155
|
:param model: Model class or table name
|
|
156
|
+
:param allow_not_null: Allow adding NOT NULL columns without a default.
|
|
153
157
|
|
|
154
158
|
>> migrator.change_fields(Model, name=pw.CharField(null=True))
|
|
155
159
|
"""
|
|
@@ -160,7 +164,7 @@ class Migrator:
|
|
|
160
164
|
|
|
161
165
|
self.__ops__.append(
|
|
162
166
|
self.__migrator__.add_column( # type: ignore[]
|
|
163
|
-
meta.table_name, field.column_name, field
|
|
167
|
+
meta.table_name, field.column_name, field, allow_not_null=allow_not_null
|
|
164
168
|
)
|
|
165
169
|
)
|
|
166
170
|
|
|
@@ -282,7 +282,7 @@ class Router(BaseRouter):
|
|
|
282
282
|
name = "{:03}_".format(num + 1) + name
|
|
283
283
|
filename = name + ".py"
|
|
284
284
|
path = self.migrate_dir / filename
|
|
285
|
-
with path.open("w") as f:
|
|
285
|
+
with path.open("w", encoding="utf-8") as f:
|
|
286
286
|
f.write(TEMPLATE.format(migrate=migrate, rollback=rollback, name=filename))
|
|
287
287
|
|
|
288
288
|
return name
|
|
@@ -14,7 +14,7 @@ Some examples (model - class or model name)::
|
|
|
14
14
|
> migrator.run(func, *args, **kwargs) # Run python function with the given args
|
|
15
15
|
> migrator.create_model(Model) # Create a model (could be used as decorator)
|
|
16
16
|
> migrator.remove_model(model, cascade=True) # Remove a model
|
|
17
|
-
> migrator.add_fields(model, **fields) # Add fields
|
|
17
|
+
> migrator.add_fields(model, **fields) # Add fields (allow_not_null=True skips default)
|
|
18
18
|
> migrator.change_fields(model, **fields) # Change fields
|
|
19
19
|
> migrator.remove_fields(model, *field_names, cascade=True)
|
|
20
20
|
> migrator.rename_field(model, old_field_name, new_field_name)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "peewee-migrate"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.3.0"
|
|
4
4
|
description = "Support for migrations in Peewee ORM"
|
|
5
5
|
requires-python = ">=3.11,<4"
|
|
6
6
|
readme = "README.rst"
|
|
@@ -97,7 +97,7 @@ project-excludes = [
|
|
|
97
97
|
addopts = "-svx"
|
|
98
98
|
|
|
99
99
|
[tool.bumpversion]
|
|
100
|
-
current_version = "2.
|
|
100
|
+
current_version = "2.3.0"
|
|
101
101
|
commit = false
|
|
102
102
|
tag = false
|
|
103
103
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "peewee-migrate"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.3.0"
|
|
4
4
|
description = "Support for migrations in Peewee ORM"
|
|
5
5
|
authors = [{ name = "Kirill Klenov", email = "horneds@gmail.com" }]
|
|
6
6
|
requires-python = ">=3.11,<4"
|
|
@@ -61,7 +61,7 @@ project-excludes = ["tests", "pyproject.toml"]
|
|
|
61
61
|
addopts = "-svx"
|
|
62
62
|
|
|
63
63
|
[tool.bumpversion]
|
|
64
|
-
current_version = "2.
|
|
64
|
+
current_version = "2.3.0"
|
|
65
65
|
commit = false
|
|
66
66
|
tag = false
|
|
67
67
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|