amsdal 0.1.26__cp310-cp310-win_amd64.whl → 0.2.0__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 +75 -3
- amsdal/contrib/frontend_configs/lifecycle/consumer.pyi +77 -6
- 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 +90 -8
- amsdal/manager.cp310-win_amd64.pyd +0 -0
- amsdal/manager.pyi +113 -25
- 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 +84 -8
- amsdal/migration/data_classes.cp310-win_amd64.pyd +0 -0
- amsdal/migration/data_classes.pyi +104 -4
- 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 +75 -5
- amsdal/migration/executors/default_executor.cp310-win_amd64.pyd +0 -0
- amsdal/migration/executors/default_executor.pyi +82 -10
- amsdal/migration/executors/state_executor.cp310-win_amd64.pyd +0 -0
- amsdal/migration/executors/state_executor.pyi +69 -5
- 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 +102 -10
- amsdal/migration/file_migration_store.cp310-win_amd64.pyd +0 -0
- amsdal/migration/file_migration_store.pyi +36 -8
- 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 +15 -2
- amsdal/migration/utils.cp310-win_amd64.pyd +0 -0
- amsdal/migration/utils.pyi +46 -6
- 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 +3 -7
- 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 +53 -2
- amsdal/schemas/manager.pyi +55 -5
- 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/helpers.py +5 -7
- {amsdal-0.1.26.dist-info → amsdal-0.2.0.dist-info}/METADATA +4 -6
- amsdal-0.2.0.dist-info/RECORD +254 -0
- amsdal/operations/__init__.cp310-win_amd64.pyd +0 -0
- amsdal/operations/__init__.pyi +0 -0
- amsdal/operations/manager.cp310-win_amd64.pyd +0 -0
- amsdal/operations/manager.pyi +0 -24
- amsdal-0.1.26.dist-info/RECORD +0 -258
- {amsdal-0.1.26.dist-info → amsdal-0.2.0.dist-info}/LICENSE.txt +0 -0
- {amsdal-0.1.26.dist-info → amsdal-0.2.0.dist-info}/WHEEL +0 -0
- {amsdal-0.1.26.dist-info → amsdal-0.2.0.dist-info}/license_check.py +0 -0
- {amsdal-0.1.26.dist-info → amsdal-0.2.0.dist-info}/top_level.txt +0 -0
|
@@ -1,42 +1,97 @@
|
|
|
1
1
|
from amsdal_models.classes.model import Model
|
|
2
|
-
from amsdal_models.schemas.data_models.schema import ObjectSchema, PropertyData
|
|
3
2
|
from amsdal_utils.models.data_models.address import Address as Address
|
|
3
|
+
from amsdal_utils.models.data_models.schema import ObjectSchema as ObjectSchema, PropertyData as PropertyData
|
|
4
4
|
from amsdal_utils.models.enums import SchemaTypes as SchemaTypes
|
|
5
5
|
from dataclasses import dataclass
|
|
6
6
|
from enum import Enum
|
|
7
7
|
from pathlib import Path
|
|
8
8
|
|
|
9
9
|
class Action(str, Enum):
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
"""
|
|
11
|
+
Enumeration for different types of actions.
|
|
12
|
+
|
|
13
|
+
Attributes:
|
|
14
|
+
CREATED (str): Represents a created action.
|
|
15
|
+
UPDATED (str): Represents an updated action.
|
|
16
|
+
NO_ACTION (str): Represents no action.
|
|
17
|
+
"""
|
|
18
|
+
CREATE = 'CREATE'
|
|
19
|
+
UPDATE = 'UPDATE'
|
|
12
20
|
NO_ACTION = 'NO_ACTION'
|
|
13
21
|
|
|
14
22
|
@dataclass
|
|
15
23
|
class ClassSaveResult:
|
|
24
|
+
"""
|
|
25
|
+
Data class representing the result of a class save operation.
|
|
26
|
+
|
|
27
|
+
Attributes:
|
|
28
|
+
action (Action): The action performed during the save operation.
|
|
29
|
+
instance (Model): The instance of the model that was saved.
|
|
30
|
+
"""
|
|
16
31
|
action: Action
|
|
17
32
|
instance: Model
|
|
18
33
|
def __init__(self, action, instance) -> None: ...
|
|
19
34
|
|
|
35
|
+
@dataclass
|
|
36
|
+
class CheckClassResult:
|
|
37
|
+
action: Action
|
|
38
|
+
instance: Model | None = ...
|
|
39
|
+
def __init__(self, action, instance=...) -> None: ...
|
|
40
|
+
|
|
20
41
|
@dataclass
|
|
21
42
|
class ClassUpdateResult:
|
|
43
|
+
"""
|
|
44
|
+
Data class representing the result of a class update operation.
|
|
45
|
+
|
|
46
|
+
Attributes:
|
|
47
|
+
is_updated (bool): Indicates whether the class was updated.
|
|
48
|
+
class_instance (Model): The instance of the model that was updated.
|
|
49
|
+
"""
|
|
22
50
|
is_updated: bool
|
|
23
51
|
class_instance: Model
|
|
24
52
|
def __init__(self, is_updated, class_instance) -> None: ...
|
|
25
53
|
|
|
26
54
|
@dataclass
|
|
27
55
|
class MigrateResult:
|
|
56
|
+
"""
|
|
57
|
+
Data class representing the result of a migration operation.
|
|
58
|
+
|
|
59
|
+
Attributes:
|
|
60
|
+
class_instance (Model): The instance of the model that was migrated.
|
|
61
|
+
is_table_created (bool): Indicates whether the table was created during the migration.
|
|
62
|
+
is_data_migrated (bool): Indicates whether the data was migrated.
|
|
63
|
+
"""
|
|
28
64
|
class_instance: Model
|
|
29
65
|
is_table_created: bool
|
|
30
66
|
is_data_migrated: bool
|
|
31
67
|
def __init__(self, class_instance, is_table_created, is_data_migrated) -> None: ...
|
|
32
68
|
|
|
33
69
|
class ModuleTypes(str, Enum):
|
|
70
|
+
"""
|
|
71
|
+
Enumeration for different types of modules.
|
|
72
|
+
|
|
73
|
+
Attributes:
|
|
74
|
+
APP (str): Represents an application module.
|
|
75
|
+
CORE (str): Represents a core module.
|
|
76
|
+
CONTRIB (str): Represents a contributed module.
|
|
77
|
+
"""
|
|
34
78
|
APP = 'APP'
|
|
35
79
|
CORE = 'CORE'
|
|
36
80
|
CONTRIB = 'CONTRIB'
|
|
37
81
|
|
|
38
82
|
@dataclass
|
|
39
83
|
class MigrationFile:
|
|
84
|
+
"""
|
|
85
|
+
Data class representing a migration file.
|
|
86
|
+
|
|
87
|
+
Attributes:
|
|
88
|
+
path (Path): The file path of the migration.
|
|
89
|
+
type (ModuleTypes): The type of module the migration belongs to.
|
|
90
|
+
number (int): The migration number.
|
|
91
|
+
module (str | None): The module name, if applicable.
|
|
92
|
+
applied_at (float | None): The timestamp when the migration was applied.
|
|
93
|
+
stored_address (Address | None): The stored address associated with the migration.
|
|
94
|
+
"""
|
|
40
95
|
path: Path
|
|
41
96
|
type: ModuleTypes
|
|
42
97
|
number: int
|
|
@@ -44,22 +99,53 @@ class MigrationFile:
|
|
|
44
99
|
applied_at: float | None = ...
|
|
45
100
|
stored_address: Address | None = ...
|
|
46
101
|
@property
|
|
47
|
-
def is_initial(self) -> bool:
|
|
102
|
+
def is_initial(self) -> bool:
|
|
103
|
+
"""
|
|
104
|
+
Indicates whether this migration is the initial migration.
|
|
105
|
+
|
|
106
|
+
Returns:
|
|
107
|
+
bool: True if this is the initial migration, False otherwise.
|
|
108
|
+
"""
|
|
48
109
|
def __init__(self, path, type, number, module=..., applied_at=..., stored_address=...) -> None: ...
|
|
49
110
|
|
|
50
111
|
@dataclass
|
|
51
112
|
class ClassSchema:
|
|
113
|
+
"""
|
|
114
|
+
Data class representing a class schema.
|
|
115
|
+
|
|
116
|
+
Attributes:
|
|
117
|
+
object_schema (ObjectSchema): The object schema associated with the class.
|
|
118
|
+
type (ModuleTypes): The type of module the class belongs to.
|
|
119
|
+
"""
|
|
52
120
|
object_schema: ObjectSchema
|
|
53
121
|
type: ModuleTypes
|
|
54
122
|
def __init__(self, object_schema, type) -> None: ...
|
|
55
123
|
|
|
56
124
|
class OperationTypes(str, Enum):
|
|
125
|
+
"""
|
|
126
|
+
Enumeration for different types of operations.
|
|
127
|
+
|
|
128
|
+
Attributes:
|
|
129
|
+
CREATE_CLASS (str): Represents the operation to create a class.
|
|
130
|
+
UPDATE_CLASS (str): Represents the operation to update a class.
|
|
131
|
+
DELETE_CLASS (str): Represents the operation to delete a class.
|
|
132
|
+
"""
|
|
57
133
|
CREATE_CLASS = 'CREATE_CLASS'
|
|
58
134
|
UPDATE_CLASS = 'UPDATE_CLASS'
|
|
59
135
|
DELETE_CLASS = 'DELETE_CLASS'
|
|
60
136
|
|
|
61
137
|
@dataclass
|
|
62
138
|
class MigrateOperation:
|
|
139
|
+
"""
|
|
140
|
+
Data class representing a migration operation.
|
|
141
|
+
|
|
142
|
+
Attributes:
|
|
143
|
+
type (OperationTypes): The type of operation being performed.
|
|
144
|
+
class_name (str): The name of the class involved in the migration.
|
|
145
|
+
schema_type (SchemaTypes): The type of schema associated with the migration.
|
|
146
|
+
old_schema (ObjectSchema | PropertyData | None): The old schema before the migration, if applicable.
|
|
147
|
+
new_schema (ObjectSchema | PropertyData | None): The new schema after the migration, if applicable.
|
|
148
|
+
"""
|
|
63
149
|
type: OperationTypes
|
|
64
150
|
class_name: str
|
|
65
151
|
schema_type: SchemaTypes
|
|
@@ -68,11 +154,25 @@ class MigrateOperation:
|
|
|
68
154
|
def __init__(self, type, class_name, schema_type, old_schema=..., new_schema=...) -> None: ...
|
|
69
155
|
|
|
70
156
|
class MigrationDirection(str, Enum):
|
|
157
|
+
"""
|
|
158
|
+
Enumeration for the direction of a migration.
|
|
159
|
+
|
|
160
|
+
Attributes:
|
|
161
|
+
FORWARD (str): Represents a forward migration.
|
|
162
|
+
BACKWARD (str): Represents a backward migration.
|
|
163
|
+
"""
|
|
71
164
|
FORWARD = 'forward'
|
|
72
165
|
BACKWARD = 'backward'
|
|
73
166
|
|
|
74
167
|
@dataclass
|
|
75
168
|
class MigrationResult:
|
|
169
|
+
"""
|
|
170
|
+
Data class representing the result of a migration.
|
|
171
|
+
|
|
172
|
+
Attributes:
|
|
173
|
+
direction (MigrationDirection): The direction of the migration.
|
|
174
|
+
migration (MigrationFile): The migration file associated with the migration.
|
|
175
|
+
"""
|
|
76
176
|
direction: MigrationDirection
|
|
77
177
|
migration: MigrationFile
|
|
78
178
|
def __init__(self, direction, migration) -> None: ...
|
|
Binary file
|
|
Binary file
|
|
@@ -2,11 +2,23 @@ import abc
|
|
|
2
2
|
from _typeshed import Incomplete
|
|
3
3
|
from abc import ABC, abstractmethod
|
|
4
4
|
from amsdal.migration.base_migration_schemas import BaseMigrationSchemas as BaseMigrationSchemas
|
|
5
|
-
from
|
|
5
|
+
from amsdal_utils.models.data_models.schema import ObjectSchema as ObjectSchema
|
|
6
6
|
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
|
|
@@ -1,24 +1,96 @@
|
|
|
1
1
|
from _typeshed import Incomplete
|
|
2
2
|
from amsdal.migration.base_migration_schemas import BaseMigrationSchemas as BaseMigrationSchemas
|
|
3
|
-
from amsdal.migration.data_classes import Action as Action,
|
|
3
|
+
from amsdal.migration.data_classes import Action as Action, CheckClassResult as CheckClassResult
|
|
4
4
|
from amsdal.migration.executors.base import BaseMigrationExecutor as BaseMigrationExecutor
|
|
5
|
-
from amsdal.migration.utils import object_schema_to_table_schema as object_schema_to_table_schema
|
|
6
5
|
from amsdal_models.classes.model import Model
|
|
7
|
-
from
|
|
6
|
+
from amsdal_utils.models.data_models.schema import ObjectSchema
|
|
8
7
|
from amsdal_utils.models.enums import SchemaTypes, Versions
|
|
9
8
|
from typing import Any
|
|
10
9
|
|
|
11
10
|
class DefaultMigrationExecutor(BaseMigrationExecutor):
|
|
11
|
+
"""
|
|
12
|
+
Default implementation of the BaseMigrationExecutor for handling database schema migrations.
|
|
13
|
+
|
|
14
|
+
This class provides concrete implementations for creating, updating, and deleting classes
|
|
15
|
+
in the database schema. It also manages schema migration buffers and processes object schemas.
|
|
16
|
+
"""
|
|
12
17
|
schemas: Incomplete
|
|
13
18
|
_table_schemas_manager: Incomplete
|
|
14
19
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
def create_class(self, schemas: BaseMigrationSchemas, class_name: str, object_schema: ObjectSchema, schema_type: SchemaTypes) -> None:
|
|
21
|
+
"""
|
|
22
|
+
Creates a class in the database schema.
|
|
23
|
+
|
|
24
|
+
This method registers a new class version if the schema type is `TYPE` and the class name
|
|
25
|
+
is not `BaseClasses.OBJECT`.
|
|
26
|
+
Otherwise, it buffers the class migration operation for further processing.
|
|
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 schema of the object to be created.
|
|
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 appends the given class name, object schema, and schema type to both
|
|
42
|
+
the non-flushable buffer and the main buffer for further processing.
|
|
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 removes the specified class from the database schema and unregisters it from the migration schemas.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
schemas (BaseMigrationSchemas): The migration schemas used for the operations.
|
|
61
|
+
class_name (str): The name of the class to be deleted.
|
|
62
|
+
schema_type (SchemaTypes): The type of the schema.
|
|
63
|
+
|
|
64
|
+
Returns:
|
|
65
|
+
None
|
|
66
|
+
"""
|
|
67
|
+
def flush_buffer(self) -> None:
|
|
68
|
+
"""
|
|
69
|
+
Flushes the migration buffer and processes the buffered classes.
|
|
70
|
+
|
|
71
|
+
This method registers the buffered classes in the migration schemas, compiles the buffered classes,
|
|
72
|
+
and processes each class in the buffer to create tables, save class objects, and migrate historical data.
|
|
73
|
+
Finally, it clears the main migration buffer.
|
|
74
|
+
|
|
75
|
+
Returns:
|
|
76
|
+
None
|
|
77
|
+
"""
|
|
78
|
+
@staticmethod
|
|
79
|
+
def _check_class(base_class: type[Model], object_schema: ObjectSchema) -> CheckClassResult: ...
|
|
80
|
+
def _save_class(self, base_class: type[Model], object_schema: ObjectSchema, class_object: Model | None, schema_type: SchemaTypes) -> None: ...
|
|
81
|
+
def _save_object_class_meta(self, base_class: type[Model], object_schema: ObjectSchema, schema_type: SchemaTypes) -> None: ...
|
|
82
|
+
def _create_table(self, object_schema: ObjectSchema, class_version: str | Versions, using: str | None = None) -> None: ...
|
|
21
83
|
def _migrate_historical_data(self, schemas: BaseMigrationSchemas, class_name: str, prior_version: str, new_version: str) -> None: ...
|
|
22
84
|
def _clean_data(self, model_class: type[Model], data: dict[str, Any]) -> dict[str, Any]: ...
|
|
23
85
|
def _process_object_schema(self, object_schema: ObjectSchema, class_name: str, buffer: list[tuple[str, ObjectSchema, SchemaTypes]]) -> ObjectSchema: ...
|
|
24
|
-
def register_schemas(self) -> None:
|
|
86
|
+
def register_schemas(self) -> None:
|
|
87
|
+
"""
|
|
88
|
+
Registers the schemas in the table schemas manager.
|
|
89
|
+
|
|
90
|
+
This method retrieves the object schemas from the database, processes them, and registers
|
|
91
|
+
them in the table schemas manager. It handles both `ClassObject` and `ClassObjectMeta` schemas,
|
|
92
|
+
and ensures that all necessary references are loaded and processed.
|
|
93
|
+
|
|
94
|
+
Returns:
|
|
95
|
+
None
|
|
96
|
+
"""
|
|
Binary file
|
|
@@ -1,14 +1,78 @@
|
|
|
1
1
|
from _typeshed import Incomplete
|
|
2
2
|
from amsdal.migration.base_migration_schemas import BaseMigrationSchemas as BaseMigrationSchemas
|
|
3
3
|
from amsdal.migration.executors.base import BaseMigrationExecutor as BaseMigrationExecutor
|
|
4
|
-
from
|
|
4
|
+
from amsdal_utils.models.data_models.schema import ObjectSchema as 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
|