amsdal 0.1.25__cp310-cp310-win_amd64.whl → 0.1.27__cp310-cp310-win_amd64.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.
Potentially problematic release.
This version of amsdal might be problematic. Click here for more details.
- amsdal/__about__.py +1 -1
- amsdal/cloud/__init__.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/client.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/client.pyi +46 -2
- amsdal/cloud/constants.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/enums.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/enums.pyi +46 -0
- amsdal/cloud/models/__init__.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/models/base.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/models/base.pyi +156 -0
- amsdal/cloud/services/__init__.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/__init__.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/add_allowlist_ip.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/add_allowlist_ip.pyi +16 -1
- amsdal/cloud/services/actions/add_basic_auth.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/add_basic_auth.pyi +17 -1
- amsdal/cloud/services/actions/add_dependency.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/add_dependency.pyi +16 -1
- amsdal/cloud/services/actions/add_secret.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/add_secret.pyi +17 -1
- amsdal/cloud/services/actions/base.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/base.pyi +71 -3
- amsdal/cloud/services/actions/create_deploy.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/create_deploy.pyi +33 -3
- amsdal/cloud/services/actions/create_env.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/create_env.pyi +15 -1
- amsdal/cloud/services/actions/create_session.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/create_session.pyi +13 -1
- amsdal/cloud/services/actions/delete_allowlist_ip.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/delete_allowlist_ip.pyi +16 -1
- amsdal/cloud/services/actions/delete_basic_auth.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/delete_basic_auth.pyi +17 -1
- amsdal/cloud/services/actions/delete_dependency.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/delete_dependency.pyi +18 -1
- amsdal/cloud/services/actions/delete_env.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/delete_env.pyi +17 -1
- amsdal/cloud/services/actions/delete_secret.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/delete_secret.pyi +18 -1
- amsdal/cloud/services/actions/destroy_deploy.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/destroy_deploy.pyi +15 -1
- amsdal/cloud/services/actions/expose_db.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/expose_db.pyi +18 -1
- amsdal/cloud/services/actions/get_basic_auth_credentials.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/get_basic_auth_credentials.pyi +17 -1
- amsdal/cloud/services/actions/get_monitoring_info.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/get_monitoring_info.pyi +17 -1
- amsdal/cloud/services/actions/list_dependencies.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/list_dependencies.pyi +17 -1
- amsdal/cloud/services/actions/list_deploys.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/list_deploys.pyi +15 -1
- amsdal/cloud/services/actions/list_envs.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/list_envs.pyi +16 -1
- amsdal/cloud/services/actions/list_secrets.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/list_secrets.pyi +18 -1
- amsdal/cloud/services/actions/manager.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/manager.pyi +254 -20
- amsdal/cloud/services/actions/signup_action.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/signup_action.pyi +16 -1
- amsdal/cloud/services/actions/update_deploy.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/update_deploy.pyi +15 -1
- amsdal/cloud/services/auth/__init__.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/auth/base.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/auth/credentials.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/auth/credentials.pyi +12 -1
- amsdal/cloud/services/auth/manager.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/auth/manager.pyi +15 -1
- amsdal/cloud/services/auth/signup_service.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/auth/signup_service.pyi +16 -1
- amsdal/cloud/services/auth/token.cp310-win_amd64.pyd +0 -0
- amsdal/cloud/services/auth/token.pyi +15 -1
- amsdal/configs/constants.py +10 -0
- amsdal/configs/constants.pyi +11 -1
- amsdal/configs/main.py +132 -19
- amsdal/configs/main.pyi +140 -10
- amsdal/context/manager.py +39 -0
- amsdal/context/manager.pyi +41 -3
- amsdal/contrib/__init__.cp310-win_amd64.pyd +0 -0
- amsdal/contrib/auth/app.py +12 -0
- amsdal/contrib/auth/app.pyi +12 -1
- amsdal/contrib/auth/lifecycle/consumer.py +53 -0
- amsdal/contrib/auth/lifecycle/consumer.pyi +53 -3
- amsdal/contrib/auth/models/login_session/hooks/pre_init.py +13 -0
- amsdal/contrib/auth/models/login_session/modifiers/display_name.py +8 -0
- amsdal/contrib/auth/models/permission/modifiers/display_name.py +8 -0
- amsdal/contrib/auth/models/user/hooks/post_init.py +13 -0
- amsdal/contrib/auth/models/user/hooks/pre_create.py +6 -0
- amsdal/contrib/auth/models/user/modifiers/display_name.py +8 -0
- amsdal/contrib/auth/settings.py +15 -0
- amsdal/contrib/auth/settings.pyi +14 -0
- amsdal/contrib/frontend_configs/app.py +14 -0
- amsdal/contrib/frontend_configs/app.pyi +14 -1
- amsdal/contrib/frontend_configs/conversion/convert.py +14 -0
- amsdal/contrib/frontend_configs/conversion/convert.pyi +15 -1
- amsdal/contrib/frontend_configs/lifecycle/consumer.py +72 -0
- amsdal/contrib/frontend_configs/lifecycle/consumer.pyi +76 -5
- amsdal/contrib/frontend_configs/models/frontent_config_control_action/properties/action_validate.py +16 -0
- amsdal/contrib/frontend_configs/utils.py +12 -1
- amsdal/contrib/frontend_configs/utils.pyi +12 -1
- amsdal/fixtures/__init__.cp310-win_amd64.pyd +0 -0
- amsdal/fixtures/manager.cp310-win_amd64.pyd +0 -0
- amsdal/fixtures/manager.pyi +88 -6
- amsdal/manager.cp310-win_amd64.pyd +0 -0
- amsdal/manager.pyi +113 -17
- amsdal/migration/__init__.cp310-win_amd64.pyd +0 -0
- amsdal/migration/base_migration_schemas.cp310-win_amd64.pyd +0 -0
- amsdal/migration/base_migration_schemas.pyi +81 -5
- amsdal/migration/data_classes.cp310-win_amd64.pyd +0 -0
- amsdal/migration/data_classes.pyi +95 -1
- amsdal/migration/executors/__init__.cp310-win_amd64.pyd +0 -0
- amsdal/migration/executors/base.cp310-win_amd64.pyd +0 -0
- amsdal/migration/executors/base.pyi +74 -4
- amsdal/migration/executors/default_executor.cp310-win_amd64.pyd +0 -0
- amsdal/migration/executors/default_executor.pyi +75 -5
- amsdal/migration/executors/state_executor.cp310-win_amd64.pyd +0 -0
- amsdal/migration/executors/state_executor.pyi +68 -4
- amsdal/migration/file_migration_executor.cp310-win_amd64.pyd +0 -0
- amsdal/migration/file_migration_executor.pyi +34 -2
- amsdal/migration/file_migration_generator.cp310-win_amd64.pyd +0 -0
- amsdal/migration/file_migration_generator.pyi +100 -8
- amsdal/migration/file_migration_store.cp310-win_amd64.pyd +0 -0
- amsdal/migration/file_migration_store.pyi +33 -3
- amsdal/migration/file_migration_writer.cp310-win_amd64.pyd +0 -0
- amsdal/migration/file_migration_writer.pyi +60 -5
- amsdal/migration/migrations.cp310-win_amd64.pyd +0 -0
- amsdal/migration/migrations.pyi +111 -6
- amsdal/migration/migrations_loader.cp310-win_amd64.pyd +0 -0
- amsdal/migration/migrations_loader.pyi +17 -2
- amsdal/migration/schemas_loaders.cp310-win_amd64.pyd +0 -0
- amsdal/migration/schemas_loaders.pyi +14 -1
- amsdal/migration/utils.cp310-win_amd64.pyd +0 -0
- amsdal/migration/utils.pyi +44 -4
- amsdal/mixins/__init__.cp310-win_amd64.pyd +0 -0
- amsdal/mixins/build_mixin.cp310-win_amd64.pyd +0 -0
- amsdal/mixins/build_mixin.pyi +60 -8
- amsdal/mixins/class_versions_mixin.cp310-win_amd64.pyd +0 -0
- amsdal/mixins/class_versions_mixin.pyi +20 -2
- amsdal/operations/__init__.cp310-win_amd64.pyd +0 -0
- amsdal/operations/manager.cp310-win_amd64.pyd +0 -0
- amsdal/operations/manager.pyi +31 -3
- amsdal/schemas/core/class_object/properties/display_name.py +6 -0
- amsdal/schemas/core/file/hooks/pre_create.py +9 -0
- amsdal/schemas/core/file/hooks/pre_update.py +9 -0
- amsdal/schemas/core/file/properties/from_file.py +12 -0
- amsdal/schemas/core/file/properties/mimetype.py +8 -0
- amsdal/schemas/core/file/properties/to_file.py +12 -0
- amsdal/schemas/core/file/properties/validate_data.py +13 -0
- amsdal/schemas/manager.cp310-win_amd64.pyd +0 -0
- amsdal/schemas/manager.py +51 -0
- amsdal/schemas/manager.pyi +54 -4
- amsdal/services/__init__.cp310-win_amd64.pyd +0 -0
- amsdal/services/transaction_execution.cp310-win_amd64.pyd +0 -0
- amsdal/services/transaction_execution.pyi +52 -3
- amsdal/utils/contrib_paths.py +10 -0
- amsdal/utils/contrib_paths.pyi +11 -1
- amsdal/utils/tests/factories.py +49 -0
- {amsdal-0.1.25.dist-info → amsdal-0.1.27.dist-info}/METADATA +5 -1
- amsdal-0.1.27.dist-info/RECORD +258 -0
- amsdal-0.1.25.dist-info/RECORD +0 -257
- {amsdal-0.1.25.dist-info → amsdal-0.1.27.dist-info}/LICENSE.txt +0 -0
- {amsdal-0.1.25.dist-info → amsdal-0.1.27.dist-info}/WHEEL +0 -0
- {amsdal-0.1.25.dist-info → amsdal-0.1.27.dist-info}/license_check.py +0 -0
- {amsdal-0.1.25.dist-info → amsdal-0.1.27.dist-info}/top_level.txt +0 -0
|
@@ -7,6 +7,18 @@ from amsdal_utils.models.enums import SchemaTypes as SchemaTypes
|
|
|
7
7
|
from pydantic import BaseModel
|
|
8
8
|
|
|
9
9
|
class FieldDescription(BaseModel):
|
|
10
|
+
"""
|
|
11
|
+
Represents a description of a field in a database schema.
|
|
12
|
+
|
|
13
|
+
This class holds information about a field, including its name, ID, type,
|
|
14
|
+
and whether it has been marked as deleted.
|
|
15
|
+
|
|
16
|
+
Attributes:
|
|
17
|
+
field_name (str): The name of the field.
|
|
18
|
+
field_id (str): The unique identifier of the field.
|
|
19
|
+
field_type (str): The type of the field.
|
|
20
|
+
is_deleted (bool): Indicates whether the field is marked as deleted.
|
|
21
|
+
"""
|
|
10
22
|
field_name: str
|
|
11
23
|
field_id: str
|
|
12
24
|
field_type: str
|
|
@@ -18,19 +30,77 @@ def _id_for_column(field_name: str, iteration: str | int) -> str: ...
|
|
|
18
30
|
def _new_table_schemas(previous_scheme: ObjectSchema | None, new_scheme: ObjectSchema, iteration: int, existing_table_structure: list[FieldDescription]) -> None: ...
|
|
19
31
|
|
|
20
32
|
class BaseMigrationExecutor(ABC, metaclass=abc.ABCMeta):
|
|
33
|
+
"""
|
|
34
|
+
Abstract base class for executing migration operations on database schemas.
|
|
35
|
+
|
|
36
|
+
This class provides methods for creating, updating, and deleting classes in the database schema.
|
|
37
|
+
It also manages schema migration buffers and generates full object schemas based on the migration history.
|
|
38
|
+
"""
|
|
21
39
|
schemas: BaseMigrationSchemas
|
|
22
40
|
_buffer: Incomplete
|
|
23
41
|
_non_flushable_buffer: Incomplete
|
|
24
42
|
def __init__(self) -> None: ...
|
|
25
|
-
def generate_full_object_schema(self, class_name: str, object_schema: ObjectSchema, buffer: list[tuple[str, ObjectSchema, SchemaTypes]]) -> list[FieldDescription]:
|
|
43
|
+
def generate_full_object_schema(self, class_name: str, object_schema: ObjectSchema, buffer: list[tuple[str, ObjectSchema, SchemaTypes]]) -> list[FieldDescription]:
|
|
44
|
+
"""
|
|
45
|
+
Generates the full object schema based on the migration history.
|
|
46
|
+
|
|
47
|
+
This method constructs the full object schema for a given class by iterating through
|
|
48
|
+
the migration history buffer and applying schema changes in sequence.
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
class_name (str): The name of the class for which the schema is being generated.
|
|
52
|
+
object_schema (ObjectSchema): The current object schema.
|
|
53
|
+
buffer (list[tuple[str, ObjectSchema, SchemaTypes]]): The migration history buffer.
|
|
54
|
+
|
|
55
|
+
Returns:
|
|
56
|
+
list[FieldDescription]: A list of field descriptions representing the full object schema.
|
|
57
|
+
"""
|
|
26
58
|
@abstractmethod
|
|
27
59
|
def create_class(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None: ...
|
|
28
60
|
@abstractmethod
|
|
29
61
|
def update_class(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None: ...
|
|
30
62
|
@abstractmethod
|
|
31
63
|
def delete_class(self, schemas: BaseMigrationSchemas, class_name: str, schema_type: SchemaTypes) -> None: ...
|
|
32
|
-
def forward_schema(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None:
|
|
64
|
+
def forward_schema(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None:
|
|
65
|
+
"""
|
|
66
|
+
Forwards the schema to the non-flushable buffer.
|
|
67
|
+
|
|
68
|
+
This method appends the given class name, object schema, and schema type to the
|
|
69
|
+
non-flushable buffer for further processing.
|
|
70
|
+
|
|
71
|
+
Args:
|
|
72
|
+
schemas (BaseMigrationSchemas): The migration schemas used for the operations.
|
|
73
|
+
class_name (str): The name of the class for which the schema is being forwarded.
|
|
74
|
+
object_schema (ObjectSchema): The current object schema.
|
|
75
|
+
schema_type (SchemaTypes): The type of the schema.
|
|
76
|
+
|
|
77
|
+
Returns:
|
|
78
|
+
None
|
|
79
|
+
"""
|
|
33
80
|
@staticmethod
|
|
34
81
|
def _resolve_base_class_name(class_name: str, meta_class: str) -> str: ...
|
|
35
|
-
def buffer_class_migration(self, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None:
|
|
36
|
-
|
|
82
|
+
def buffer_class_migration(self, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None:
|
|
83
|
+
"""
|
|
84
|
+
Buffers the class migration operation.
|
|
85
|
+
|
|
86
|
+
This method appends the given class name, object schema, and schema type to both
|
|
87
|
+
the non-flushable buffer and the main buffer for further processing.
|
|
88
|
+
|
|
89
|
+
Args:
|
|
90
|
+
class_name (str): The name of the class for which the migration is being buffered.
|
|
91
|
+
object_schema (ObjectSchema): The current object schema.
|
|
92
|
+
schema_type (SchemaTypes): The type of the schema.
|
|
93
|
+
|
|
94
|
+
Returns:
|
|
95
|
+
None
|
|
96
|
+
"""
|
|
97
|
+
def flush_buffer(self) -> None:
|
|
98
|
+
"""
|
|
99
|
+
Flushes the migration buffer.
|
|
100
|
+
|
|
101
|
+
This method clears all entries from the main migration buffer, effectively
|
|
102
|
+
resetting it for future migration operations.
|
|
103
|
+
|
|
104
|
+
Returns:
|
|
105
|
+
None
|
|
106
|
+
"""
|
|
Binary file
|
|
@@ -9,16 +9,86 @@ from amsdal_utils.models.enums import SchemaTypes, Versions
|
|
|
9
9
|
from typing import Any
|
|
10
10
|
|
|
11
11
|
class DefaultMigrationExecutor(BaseMigrationExecutor):
|
|
12
|
+
"""
|
|
13
|
+
Default implementation of the BaseMigrationExecutor for handling database schema migrations.
|
|
14
|
+
|
|
15
|
+
This class provides concrete implementations for creating, updating, and deleting classes
|
|
16
|
+
in the database schema. It also manages schema migration buffers and processes object schemas.
|
|
17
|
+
"""
|
|
12
18
|
schemas: Incomplete
|
|
13
19
|
_table_schemas_manager: Incomplete
|
|
14
20
|
def __init__(self, schemas: BaseMigrationSchemas) -> None: ...
|
|
15
|
-
def create_class(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
def create_class(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None:
|
|
22
|
+
"""
|
|
23
|
+
Creates a class in the database schema.
|
|
24
|
+
|
|
25
|
+
This method registers a new class version if the schema type is `TYPE` and the class name
|
|
26
|
+
is not `BaseClasses.OBJECT`.
|
|
27
|
+
Otherwise, it buffers the class migration operation for further processing.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
schemas (BaseMigrationSchemas): The migration schemas used for the operations.
|
|
31
|
+
class_name (str): The name of the class to be created.
|
|
32
|
+
object_schema (ObjectSchema): The schema of the object to be created.
|
|
33
|
+
schema_type (SchemaTypes): The type of the schema.
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
None
|
|
37
|
+
"""
|
|
38
|
+
def update_class(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None:
|
|
39
|
+
"""
|
|
40
|
+
Buffers the class update operation.
|
|
41
|
+
|
|
42
|
+
This method appends the given class name, object schema, and schema type to both
|
|
43
|
+
the non-flushable buffer and the main buffer for further processing.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
schemas (BaseMigrationSchemas): The migration schemas used for the operations.
|
|
47
|
+
class_name (str): The name of the class to be updated.
|
|
48
|
+
object_schema (ObjectSchema): The current object schema.
|
|
49
|
+
schema_type (SchemaTypes): The type of the schema.
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
None
|
|
53
|
+
"""
|
|
54
|
+
def delete_class(self, schemas: BaseMigrationSchemas, class_name: str, schema_type: SchemaTypes) -> None:
|
|
55
|
+
"""
|
|
56
|
+
Deletes a class from the database schema.
|
|
57
|
+
|
|
58
|
+
This method removes the specified class from the database schema and unregisters it from the migration schemas.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
schemas (BaseMigrationSchemas): The migration schemas used for the operations.
|
|
62
|
+
class_name (str): The name of the class to be deleted.
|
|
63
|
+
schema_type (SchemaTypes): The type of the schema.
|
|
64
|
+
|
|
65
|
+
Returns:
|
|
66
|
+
None
|
|
67
|
+
"""
|
|
68
|
+
def flush_buffer(self) -> None:
|
|
69
|
+
"""
|
|
70
|
+
Flushes the migration buffer and processes the buffered classes.
|
|
71
|
+
|
|
72
|
+
This method registers the buffered classes in the migration schemas, compiles the buffered classes,
|
|
73
|
+
and processes each class in the buffer to create tables, save class objects, and migrate historical data.
|
|
74
|
+
Finally, it clears the main migration buffer.
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
None
|
|
78
|
+
"""
|
|
19
79
|
def _save_class(self, base_class: type[Model], object_schema: ObjectSchema, schema_type: SchemaTypes) -> ClassSaveResult: ...
|
|
20
80
|
def _create_table(self, object_schema: ObjectSchema, class_version: str | Versions) -> None: ...
|
|
21
81
|
def _migrate_historical_data(self, schemas: BaseMigrationSchemas, class_name: str, prior_version: str, new_version: str) -> None: ...
|
|
22
82
|
def _clean_data(self, model_class: type[Model], data: dict[str, Any]) -> dict[str, Any]: ...
|
|
23
83
|
def _process_object_schema(self, object_schema: ObjectSchema, class_name: str, buffer: list[tuple[str, ObjectSchema, SchemaTypes]]) -> ObjectSchema: ...
|
|
24
|
-
def register_schemas(self) -> None:
|
|
84
|
+
def register_schemas(self) -> None:
|
|
85
|
+
"""
|
|
86
|
+
Registers the schemas in the table schemas manager.
|
|
87
|
+
|
|
88
|
+
This method retrieves the object schemas from the database, processes them, and registers
|
|
89
|
+
them in the table schemas manager. It handles both `ClassObject` and `ClassObjectMeta` schemas,
|
|
90
|
+
and ensures that all necessary references are loaded and processed.
|
|
91
|
+
|
|
92
|
+
Returns:
|
|
93
|
+
None
|
|
94
|
+
"""
|
|
Binary file
|
|
@@ -5,10 +5,74 @@ from amsdal_models.schemas.data_models.schema import ObjectSchema
|
|
|
5
5
|
from amsdal_utils.models.enums import SchemaTypes
|
|
6
6
|
|
|
7
7
|
class StateMigrationExecutor(BaseMigrationExecutor):
|
|
8
|
+
"""
|
|
9
|
+
Executes state migrations for database schemas.
|
|
10
|
+
|
|
11
|
+
This class handles the creation, updating, and deletion of classes in the database schema,
|
|
12
|
+
as well as flushing buffered migration operations.
|
|
13
|
+
|
|
14
|
+
Attributes:
|
|
15
|
+
schemas (BaseMigrationSchemas): The migration schemas used for the operations.
|
|
16
|
+
do_fetch_latest_version (bool): Flag indicating whether to fetch the latest version of the schema.
|
|
17
|
+
"""
|
|
8
18
|
schemas: Incomplete
|
|
9
19
|
do_fetch_latest_version: Incomplete
|
|
10
20
|
def __init__(self, schemas: BaseMigrationSchemas, *, do_fetch_latest_version: bool = True) -> None: ...
|
|
11
|
-
def create_class(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
21
|
+
def create_class(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None:
|
|
22
|
+
"""
|
|
23
|
+
Creates a class in the database schema.
|
|
24
|
+
|
|
25
|
+
This method registers a new class in the database schema or buffers the class migration
|
|
26
|
+
operation based on the schema type and class name.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
schemas (BaseMigrationSchemas): The migration schemas used for the operations.
|
|
30
|
+
class_name (str): The name of the class to be created.
|
|
31
|
+
object_schema (ObjectSchema): The current object schema.
|
|
32
|
+
schema_type (SchemaTypes): The type of the schema.
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
None
|
|
36
|
+
"""
|
|
37
|
+
def update_class(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None:
|
|
38
|
+
"""
|
|
39
|
+
Buffers the class update operation.
|
|
40
|
+
|
|
41
|
+
This method adds the class update operation to the migration buffer, which will be processed
|
|
42
|
+
when the buffer is flushed.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
schemas (BaseMigrationSchemas): The migration schemas used for the operations.
|
|
46
|
+
class_name (str): The name of the class to be updated.
|
|
47
|
+
object_schema (ObjectSchema): The current object schema.
|
|
48
|
+
schema_type (SchemaTypes): The type of the schema.
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
None
|
|
52
|
+
"""
|
|
53
|
+
def delete_class(self, schemas: BaseMigrationSchemas, class_name: str, schema_type: SchemaTypes) -> None:
|
|
54
|
+
"""
|
|
55
|
+
Deletes a class from the database schema.
|
|
56
|
+
|
|
57
|
+
This method unregisters a class from the database schema based on the provided class name
|
|
58
|
+
and schema type.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
schemas (BaseMigrationSchemas): The migration schemas used for the operations.
|
|
62
|
+
class_name (str): The name of the class to be deleted.
|
|
63
|
+
schema_type (SchemaTypes): The type of the schema.
|
|
64
|
+
|
|
65
|
+
Returns:
|
|
66
|
+
None
|
|
67
|
+
"""
|
|
68
|
+
def flush_buffer(self) -> None:
|
|
69
|
+
"""
|
|
70
|
+
Flushes the migration buffer and processes the buffered classes.
|
|
71
|
+
|
|
72
|
+
This method registers all classes in the migration buffer to the database schema and compiles
|
|
73
|
+
the buffered classes. If the `do_fetch_latest_version` flag is set, it also fetches and registers
|
|
74
|
+
the latest version of each class.
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
None
|
|
78
|
+
"""
|
|
Binary file
|
|
@@ -14,6 +14,17 @@ from amsdal_utils.models.enums import SchemaTypes
|
|
|
14
14
|
logger: Incomplete
|
|
15
15
|
|
|
16
16
|
class FileMigrationExecutorManager:
|
|
17
|
+
"""
|
|
18
|
+
Manager class for executing file migrations.
|
|
19
|
+
|
|
20
|
+
Attributes:
|
|
21
|
+
migration_address (Address): The address associated with the migration.
|
|
22
|
+
core_loader (MigrationsLoader): Loader for core migrations.
|
|
23
|
+
contrib_loaders (list[MigrationsLoader]): List of loaders for contributed migrations.
|
|
24
|
+
app_loader (MigrationsLoader): Loader for application migrations.
|
|
25
|
+
executor (BaseMigrationExecutor): The executor responsible for running migrations.
|
|
26
|
+
store (BaseMigrationStore): The store for managing migration files.
|
|
27
|
+
"""
|
|
17
28
|
migration_address: Address
|
|
18
29
|
core_loader: Incomplete
|
|
19
30
|
contrib_loaders: Incomplete
|
|
@@ -22,7 +33,19 @@ class FileMigrationExecutorManager:
|
|
|
22
33
|
_applied_migration_files: Incomplete
|
|
23
34
|
store: Incomplete
|
|
24
35
|
def __init__(self, app_migrations_loader: MigrationsLoader, executor: BaseMigrationExecutor, store: BaseMigrationStore | None = None) -> None: ...
|
|
25
|
-
def execute(self, migration_number: int | None = None, module_type: ModuleTypes | None = None, *, fake: bool = False, skip_data_migrations: bool = False) -> list[MigrationResult]:
|
|
36
|
+
def execute(self, migration_number: int | None = None, module_type: ModuleTypes | None = None, *, fake: bool = False, skip_data_migrations: bool = False) -> list[MigrationResult]:
|
|
37
|
+
"""
|
|
38
|
+
Executes the migrations.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
migration_number (int | None): The migration number to execute up to. Defaults to None.
|
|
42
|
+
module_type (ModuleTypes | None): The type of module to migrate. Defaults to None.
|
|
43
|
+
fake (bool): If True, simulates the migration without applying changes. Defaults to False.
|
|
44
|
+
skip_data_migrations (bool): If True, skips data migrations. Defaults to False.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
list[MigrationResult]: List of results from the migration execution.
|
|
48
|
+
"""
|
|
26
49
|
@staticmethod
|
|
27
50
|
def _get_contrib_loaders() -> list[MigrationsLoader]: ...
|
|
28
51
|
def _apply(self, migration_number: int | None = None, module_type: ModuleTypes | None = None, *, fake: bool = False, skip_data_migrations: bool = False) -> list[MigrationResult]: ...
|
|
@@ -30,7 +53,16 @@ class FileMigrationExecutorManager:
|
|
|
30
53
|
def _register_schemas(self, executor: BaseMigrationExecutor) -> None: ...
|
|
31
54
|
def _init_state_from_applied_migrations(self, migrations: list[MigrationFile], module_type: ModuleTypes) -> None: ...
|
|
32
55
|
@staticmethod
|
|
33
|
-
def get_migration_class(migration: MigrationFile) -> type['Migration']:
|
|
56
|
+
def get_migration_class(migration: MigrationFile) -> type['Migration']:
|
|
57
|
+
"""
|
|
58
|
+
Retrieves the migration class from the migration file.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
migration (MigrationFile): The migration file.
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
type[Migration]: The migration class.
|
|
65
|
+
"""
|
|
34
66
|
def _is_migration_applied(self, migration: MigrationFile, module_type: ModuleTypes) -> bool: ...
|
|
35
67
|
@staticmethod
|
|
36
68
|
def _map_module_type_to_schema_type(module_type: ModuleTypes) -> SchemaTypes: ...
|
|
Binary file
|
|
@@ -20,28 +20,120 @@ class StateMigrationStore(BaseMigrationStore):
|
|
|
20
20
|
def fetch_migrations(self) -> list[MigrationFile]: ...
|
|
21
21
|
|
|
22
22
|
class StateMigrationSchemas(BaseMigrationSchemas):
|
|
23
|
+
"""
|
|
24
|
+
Manages the state of migration schemas.
|
|
25
|
+
|
|
26
|
+
Attributes:
|
|
27
|
+
state (dict[str, tuple[SchemaTypes, ObjectSchema]]): A dictionary mapping class names to their schema types
|
|
28
|
+
and object schemas.
|
|
29
|
+
"""
|
|
23
30
|
state: Incomplete
|
|
24
31
|
def __init__(self) -> None: ...
|
|
25
|
-
def register_model(self, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None:
|
|
26
|
-
|
|
32
|
+
def register_model(self, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None:
|
|
33
|
+
"""
|
|
34
|
+
Registers a model with the given class name, object schema, and schema type.
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
class_name (str): The name of the class to register.
|
|
38
|
+
object_schema (ObjectSchema): The object schema of the class.
|
|
39
|
+
schema_type (SchemaTypes): The type of schema.
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
None
|
|
43
|
+
"""
|
|
44
|
+
def unregister_model(self, class_name: str) -> None:
|
|
45
|
+
"""
|
|
46
|
+
Unregisters a model with the given class name.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
class_name (str): The name of the class to unregister.
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
None
|
|
53
|
+
"""
|
|
27
54
|
def compile_buffered_classes(self) -> None: ...
|
|
28
55
|
|
|
29
56
|
class FileMigrationGenerator:
|
|
57
|
+
"""
|
|
58
|
+
Generates migration files based on schema changes.
|
|
59
|
+
"""
|
|
30
60
|
_operations: ClassVar[dict[OperationTypes, Callable[..., MigrateOperation]]]
|
|
31
61
|
_app_migrations_path: Incomplete
|
|
32
62
|
_app_migrations_loader: Incomplete
|
|
33
63
|
_schema_loader: Incomplete
|
|
34
64
|
_state: Incomplete
|
|
35
65
|
def __init__(self, schema_loader: BaseClassSchemaLoader, app_migrations_path: Path | None = None) -> None: ...
|
|
36
|
-
def make_migrations(self, name: str | None = None, *, is_data: bool = False, schema_type: SchemaTypes = ...) -> MigrationFile:
|
|
37
|
-
|
|
66
|
+
def make_migrations(self, name: str | None = None, *, is_data: bool = False, schema_type: SchemaTypes = ...) -> MigrationFile:
|
|
67
|
+
"""
|
|
68
|
+
Creates migration files based on schema changes.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
name (str | None): The name of the migration. Defaults to None.
|
|
72
|
+
is_data (bool): If True, creates a data migration. Defaults to False.
|
|
73
|
+
schema_type (SchemaTypes): The type of schema. Defaults to SchemaTypes.USER.
|
|
74
|
+
|
|
75
|
+
Returns:
|
|
76
|
+
MigrationFile: The created migration file.
|
|
77
|
+
|
|
78
|
+
Raises:
|
|
79
|
+
UserWarning: If no changes are detected.
|
|
80
|
+
"""
|
|
81
|
+
def generate_operations(self, schema_type: SchemaTypes) -> list[MigrateOperation]:
|
|
82
|
+
"""
|
|
83
|
+
Generates migration operations based on schema changes.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
schema_type (SchemaTypes): The type of schema.
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
list[MigrateOperation]: List of migration operations.
|
|
90
|
+
"""
|
|
38
91
|
def _make_data_migrations(self, name: str | None = None) -> MigrationFile: ...
|
|
39
92
|
def _init_state(self) -> None: ...
|
|
40
93
|
@classmethod
|
|
41
|
-
def build_operations(cls, schema_type: SchemaTypes, class_schema: ObjectSchema, old_class_schema: ObjectSchema | None) -> list[MigrateOperation]:
|
|
42
|
-
|
|
43
|
-
|
|
94
|
+
def build_operations(cls, schema_type: SchemaTypes, class_schema: ObjectSchema, old_class_schema: ObjectSchema | None) -> list[MigrateOperation]:
|
|
95
|
+
"""
|
|
96
|
+
Builds migration operations based on schema changes.
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
schema_type (SchemaTypes): The type of schema.
|
|
100
|
+
class_schema (ObjectSchema): The new class schema.
|
|
101
|
+
old_class_schema (ObjectSchema | None): The old class schema. Defaults to None.
|
|
102
|
+
|
|
103
|
+
Returns:
|
|
104
|
+
list[MigrateOperation]: List of migration operations.
|
|
105
|
+
"""
|
|
106
|
+
def write_migration_file(self, operations: list[MigrateOperation], name: str | None = None) -> MigrationFile:
|
|
107
|
+
"""
|
|
108
|
+
Writes migration operations to a file.
|
|
109
|
+
|
|
110
|
+
Args:
|
|
111
|
+
operations (list[MigrateOperation]): List of migration operations.
|
|
112
|
+
name (str | None): The name of the migration. Defaults to None.
|
|
113
|
+
|
|
114
|
+
Returns:
|
|
115
|
+
MigrationFile: The created migration file.
|
|
116
|
+
"""
|
|
117
|
+
def write_data_migration_file(self, name: str | None = None) -> MigrationFile:
|
|
118
|
+
"""
|
|
119
|
+
Writes data migration operations to a file.
|
|
120
|
+
|
|
121
|
+
Args:
|
|
122
|
+
name (str | None): The name of the migration. Defaults to None.
|
|
123
|
+
|
|
124
|
+
Returns:
|
|
125
|
+
MigrationFile: The created data migration file.
|
|
126
|
+
"""
|
|
44
127
|
@staticmethod
|
|
45
|
-
def generate_name_from_operations(operations: list[MigrateOperation]) -> str:
|
|
128
|
+
def generate_name_from_operations(operations: list[MigrateOperation]) -> str:
|
|
129
|
+
"""
|
|
130
|
+
Generates a name for the migration file based on operations.
|
|
131
|
+
|
|
132
|
+
Args:
|
|
133
|
+
operations (list[MigrateOperation]): List of migration operations.
|
|
134
|
+
|
|
135
|
+
Returns:
|
|
136
|
+
str: The generated name.
|
|
137
|
+
"""
|
|
46
138
|
@staticmethod
|
|
47
139
|
def _get_migration_file_name(number: int, name: str) -> str: ...
|
|
Binary file
|
|
@@ -17,14 +17,44 @@ class BaseMigrationStore(ABC, metaclass=abc.ABCMeta):
|
|
|
17
17
|
def delete_migration(self, migration: MigrationFile) -> None: ...
|
|
18
18
|
|
|
19
19
|
class FileMigrationStore(BaseMigrationStore):
|
|
20
|
+
"""
|
|
21
|
+
Manages the storage and retrieval of migration files.
|
|
22
|
+
|
|
23
|
+
Attributes:
|
|
24
|
+
migration_address (Address): The address associated with the migration.
|
|
25
|
+
"""
|
|
20
26
|
migration_address: Address
|
|
21
27
|
_config_manager: Incomplete
|
|
22
28
|
_amsdal_config: Incomplete
|
|
23
29
|
_connections_manager: Incomplete
|
|
24
30
|
def __init__(self) -> None: ...
|
|
25
|
-
def fetch_migrations(self) -> list[MigrationFile]:
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
def fetch_migrations(self) -> list[MigrationFile]:
|
|
32
|
+
"""
|
|
33
|
+
Fetches the list of applied migrations.
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
list[MigrationFile]: List of applied migration files.
|
|
37
|
+
"""
|
|
38
|
+
def save_migration(self, migration: MigrationFile) -> None:
|
|
39
|
+
"""
|
|
40
|
+
Saves a migration file.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
migration (MigrationFile): The migration file to save.
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
None
|
|
47
|
+
"""
|
|
48
|
+
def delete_migration(self, migration: MigrationFile) -> None:
|
|
49
|
+
"""
|
|
50
|
+
Deletes a migration file.
|
|
51
|
+
|
|
52
|
+
Args:
|
|
53
|
+
migration (MigrationFile): The migration file to delete.
|
|
54
|
+
|
|
55
|
+
Returns:
|
|
56
|
+
None
|
|
57
|
+
"""
|
|
28
58
|
def _save_historical_data(self, address: Address, data: dict[str, Any], metadata: dict[str, Any]) -> None: ...
|
|
29
59
|
@staticmethod
|
|
30
60
|
def _build_migration_data(migration: MigrationFile) -> dict[str, Any]: ...
|
|
Binary file
|
|
@@ -3,16 +3,71 @@ from pathlib import Path
|
|
|
3
3
|
from typing import ClassVar
|
|
4
4
|
|
|
5
5
|
class FileMigrationWriter:
|
|
6
|
+
"""
|
|
7
|
+
Handles the writing of migration files.
|
|
8
|
+
|
|
9
|
+
Attributes:
|
|
10
|
+
template_path (Path): The path to the migration template file.
|
|
11
|
+
data_template_path (Path): The path to the data migration template file.
|
|
12
|
+
operation_name_map (ClassVar[dict[OperationTypes, str]]): A mapping of operation types to their
|
|
13
|
+
string representations.
|
|
14
|
+
"""
|
|
6
15
|
template_path: Path
|
|
7
16
|
data_template_path: Path
|
|
8
17
|
operation_name_map: ClassVar[dict[OperationTypes, str]]
|
|
9
18
|
@classmethod
|
|
10
|
-
def write(cls, file_path: Path, operations: list[MigrateOperation]) -> None:
|
|
19
|
+
def write(cls, file_path: Path, operations: list[MigrateOperation]) -> None:
|
|
20
|
+
"""
|
|
21
|
+
Writes the migration operations to a file.
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
file_path (Path): The path to the migration file.
|
|
25
|
+
operations (list[MigrateOperation]): The list of migration operations to write.
|
|
26
|
+
|
|
27
|
+
Returns:
|
|
28
|
+
None
|
|
29
|
+
"""
|
|
11
30
|
@classmethod
|
|
12
|
-
def write_data_migration(cls, file_path: Path) -> None:
|
|
31
|
+
def write_data_migration(cls, file_path: Path) -> None:
|
|
32
|
+
"""
|
|
33
|
+
Writes a data migration to a file.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
file_path (Path): The path to the data migration file.
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
None
|
|
40
|
+
"""
|
|
13
41
|
@classmethod
|
|
14
|
-
def render(cls, operations: list[MigrateOperation]) -> str:
|
|
42
|
+
def render(cls, operations: list[MigrateOperation]) -> str:
|
|
43
|
+
"""
|
|
44
|
+
Renders the migration operations into a string.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
operations (list[MigrateOperation]): The list of migration operations to render.
|
|
48
|
+
|
|
49
|
+
Returns:
|
|
50
|
+
str: The rendered migration operations as a string.
|
|
51
|
+
"""
|
|
15
52
|
@classmethod
|
|
16
|
-
def render_operation(cls, operation: MigrateOperation) -> str:
|
|
53
|
+
def render_operation(cls, operation: MigrateOperation) -> str:
|
|
54
|
+
"""
|
|
55
|
+
Renders a single migration operation into a string.
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
operation (MigrateOperation): The migration operation to render.
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
str: The rendered migration operation as a string.
|
|
62
|
+
"""
|
|
17
63
|
@classmethod
|
|
18
|
-
def reformat(cls, content: str) -> str:
|
|
64
|
+
def reformat(cls, content: str) -> str:
|
|
65
|
+
"""
|
|
66
|
+
Reformats the content using the Black formatter.
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
content (str): The content to reformat.
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
str: The reformatted content.
|
|
73
|
+
"""
|
|
Binary file
|