mpt-tool 5.0.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.
- mpt_tool/__init__.py +0 -0
- mpt_tool/cli.py +76 -0
- mpt_tool/commands/__init__.py +4 -0
- mpt_tool/commands/base.py +27 -0
- mpt_tool/commands/data.py +23 -0
- mpt_tool/commands/errors.py +9 -0
- mpt_tool/commands/factory.py +45 -0
- mpt_tool/commands/fake.py +26 -0
- mpt_tool/commands/list.py +33 -0
- mpt_tool/commands/new_data.py +30 -0
- mpt_tool/commands/new_schema.py +30 -0
- mpt_tool/commands/schema.py +23 -0
- mpt_tool/commands/validators.py +24 -0
- mpt_tool/config.py +22 -0
- mpt_tool/constants.py +4 -0
- mpt_tool/enums.py +41 -0
- mpt_tool/errors.py +9 -0
- mpt_tool/managers/__init__.py +5 -0
- mpt_tool/managers/encoders.py +15 -0
- mpt_tool/managers/errors.py +25 -0
- mpt_tool/managers/file_migration.py +132 -0
- mpt_tool/managers/state/__init__.py +0 -0
- mpt_tool/managers/state/airtable.py +108 -0
- mpt_tool/managers/state/base.py +49 -0
- mpt_tool/managers/state/factory.py +32 -0
- mpt_tool/managers/state/file.py +64 -0
- mpt_tool/migration/__init__.py +4 -0
- mpt_tool/migration/base.py +25 -0
- mpt_tool/migration/data_base.py +10 -0
- mpt_tool/migration/mixins/__init__.py +4 -0
- mpt_tool/migration/mixins/airtable_client.py +29 -0
- mpt_tool/migration/mixins/mpt_client.py +31 -0
- mpt_tool/migration/schema_base.py +10 -0
- mpt_tool/models.py +140 -0
- mpt_tool/py.typed +0 -0
- mpt_tool/renders.py +30 -0
- mpt_tool/templates.py +12 -0
- mpt_tool/use_cases/__init__.py +11 -0
- mpt_tool/use_cases/apply_migration.py +42 -0
- mpt_tool/use_cases/errors.py +17 -0
- mpt_tool/use_cases/list_migrations.py +35 -0
- mpt_tool/use_cases/new_migration.py +22 -0
- mpt_tool/use_cases/run_migrations.py +98 -0
- mpt_tool-5.0.0.dist-info/METADATA +299 -0
- mpt_tool-5.0.0.dist-info/RECORD +48 -0
- mpt_tool-5.0.0.dist-info/WHEEL +4 -0
- mpt_tool-5.0.0.dist-info/entry_points.txt +2 -0
- mpt_tool-5.0.0.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from mpt_tool.enums import MigrationTypeEnum
|
|
2
|
+
from mpt_tool.managers import FileMigrationManager
|
|
3
|
+
from mpt_tool.managers.errors import CreateMigrationError
|
|
4
|
+
from mpt_tool.use_cases.errors import NewMigrationError
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class NewMigrationUseCase:
|
|
8
|
+
"""Service to create a new migration file."""
|
|
9
|
+
|
|
10
|
+
def __init__(self, file_manager: FileMigrationManager | None = None):
|
|
11
|
+
self.file_manager = file_manager or FileMigrationManager()
|
|
12
|
+
|
|
13
|
+
def execute(self, migration_type: MigrationTypeEnum, file_name: str) -> str:
|
|
14
|
+
"""Create a new migration file."""
|
|
15
|
+
try:
|
|
16
|
+
migration_file = self.file_manager.new_migration(
|
|
17
|
+
file_suffix=file_name, migration_type=migration_type
|
|
18
|
+
)
|
|
19
|
+
except CreateMigrationError as error:
|
|
20
|
+
raise NewMigrationError(str(error)) from error
|
|
21
|
+
|
|
22
|
+
return migration_file.file_name
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from mpt_tool.enums import MigrationStatusEnum, MigrationTypeEnum
|
|
4
|
+
from mpt_tool.managers import FileMigrationManager, StateManager, StateManagerFactory
|
|
5
|
+
from mpt_tool.managers.errors import LoadMigrationError, MigrationFolderError, StateNotFoundError
|
|
6
|
+
from mpt_tool.migration.base import BaseMigration
|
|
7
|
+
from mpt_tool.models import Migration, MigrationFile
|
|
8
|
+
from mpt_tool.use_cases.errors import RunMigrationError
|
|
9
|
+
|
|
10
|
+
logger = logging.getLogger(__name__)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class RunMigrationsUseCase:
|
|
14
|
+
"""Use case for running migrations."""
|
|
15
|
+
|
|
16
|
+
def __init__(
|
|
17
|
+
self,
|
|
18
|
+
file_migration_manager: FileMigrationManager | None = None,
|
|
19
|
+
state_manager: StateManager | None = None,
|
|
20
|
+
):
|
|
21
|
+
self.file_migration_manager = file_migration_manager or FileMigrationManager()
|
|
22
|
+
self.state_manager = state_manager or StateManagerFactory.get_instance()
|
|
23
|
+
|
|
24
|
+
def execute(self, migration_type: MigrationTypeEnum) -> None: # noqa: WPS231
|
|
25
|
+
"""Run all migrations of a given type.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
migration_type: The type of migrations to run.
|
|
29
|
+
|
|
30
|
+
Raises:
|
|
31
|
+
RunMigrationError: If an error occurs during migration execution.
|
|
32
|
+
"""
|
|
33
|
+
try:
|
|
34
|
+
migration_files = self.file_migration_manager.validate()
|
|
35
|
+
except MigrationFolderError as error:
|
|
36
|
+
raise RunMigrationError(str(error)) from error
|
|
37
|
+
|
|
38
|
+
for migration_file in migration_files:
|
|
39
|
+
migration_instance = self._get_migration_instance_by_type(
|
|
40
|
+
migration_file, migration_type
|
|
41
|
+
)
|
|
42
|
+
if migration_instance is None:
|
|
43
|
+
continue
|
|
44
|
+
|
|
45
|
+
state = self._get_or_create_state(
|
|
46
|
+
migration_file.migration_id, migration_type, migration_file.order_id
|
|
47
|
+
)
|
|
48
|
+
if state.applied_at is not None:
|
|
49
|
+
logger.debug("Skipping applied migration: %s", migration_file.migration_id)
|
|
50
|
+
continue
|
|
51
|
+
|
|
52
|
+
logger.info("Running migration: %s", migration_file.migration_id)
|
|
53
|
+
self._save_state(state, status=MigrationStatusEnum.RUNNING)
|
|
54
|
+
try:
|
|
55
|
+
migration_instance.run()
|
|
56
|
+
# We catch all exceptions here to ensure the state is updated
|
|
57
|
+
# and the flow is not interrupted abruptly
|
|
58
|
+
except Exception as error:
|
|
59
|
+
self._save_state(state, status=MigrationStatusEnum.FAILED)
|
|
60
|
+
raise RunMigrationError(
|
|
61
|
+
f"Migration {migration_file.migration_id} failed: {error!s}"
|
|
62
|
+
) from error
|
|
63
|
+
|
|
64
|
+
self._save_state(state, status=MigrationStatusEnum.APPLIED)
|
|
65
|
+
|
|
66
|
+
def _get_migration_instance_by_type(
|
|
67
|
+
self, migration_file: MigrationFile, migration_type: MigrationTypeEnum
|
|
68
|
+
) -> BaseMigration | None:
|
|
69
|
+
try:
|
|
70
|
+
migration_instance = self.file_migration_manager.load_migration(migration_file)
|
|
71
|
+
except LoadMigrationError as error:
|
|
72
|
+
raise RunMigrationError(str(error)) from error
|
|
73
|
+
|
|
74
|
+
if migration_instance.type != migration_type:
|
|
75
|
+
return None
|
|
76
|
+
|
|
77
|
+
return migration_instance
|
|
78
|
+
|
|
79
|
+
def _get_or_create_state(
|
|
80
|
+
self, migration_id: str, migration_type: MigrationTypeEnum, order_id: int
|
|
81
|
+
) -> Migration:
|
|
82
|
+
try:
|
|
83
|
+
state = self.state_manager.get_by_id(migration_id)
|
|
84
|
+
except StateNotFoundError:
|
|
85
|
+
state = self.state_manager.new(migration_id, migration_type, order_id)
|
|
86
|
+
|
|
87
|
+
return state
|
|
88
|
+
|
|
89
|
+
def _save_state(self, state: Migration, status: MigrationStatusEnum) -> None:
|
|
90
|
+
match status:
|
|
91
|
+
case MigrationStatusEnum.APPLIED:
|
|
92
|
+
state.applied()
|
|
93
|
+
case MigrationStatusEnum.FAILED:
|
|
94
|
+
state.failed()
|
|
95
|
+
case MigrationStatusEnum.RUNNING:
|
|
96
|
+
state.start()
|
|
97
|
+
|
|
98
|
+
self.state_manager.save_state(state)
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mpt-tool
|
|
3
|
+
Version: 5.0.0
|
|
4
|
+
Summary: Migration tool for extensions
|
|
5
|
+
Author: SoftwareOne AG
|
|
6
|
+
License: Apache-2.0 license
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Python: <4,>=3.12
|
|
9
|
+
Requires-Dist: mpt-api-client==5.0.*
|
|
10
|
+
Requires-Dist: pyairtable==3.3.*
|
|
11
|
+
Requires-Dist: typer>=0.9.0
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# mpt-tool CLI
|
|
15
|
+
|
|
16
|
+
mpt-tool is a command-line utility to scaffold, run, and audit migrations for MPT extensions.
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
1. **Install the tool:**
|
|
20
|
+
```bash
|
|
21
|
+
pip install mpt-tool
|
|
22
|
+
```
|
|
23
|
+
2. **Create your first migration:**
|
|
24
|
+
```bash
|
|
25
|
+
mpt-tool migrate --new-data sync_users
|
|
26
|
+
```
|
|
27
|
+
3. **Edit the generated file in the migrations/ folder**
|
|
28
|
+
4. **Run all pending migrations**
|
|
29
|
+
```bash
|
|
30
|
+
mpt-tool migrate --data
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
Install with pip or your favorite PyPI package manager:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install mpt-tool
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
uv add mpt-tool
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Prerequisites
|
|
46
|
+
|
|
47
|
+
- Python 3.12+ in your environment
|
|
48
|
+
- A `migrations/` folder in your project (it will be created automatically the first time you create a migration)
|
|
49
|
+
- Environment variables. See [Environment Variables](#environment-variables) for details.
|
|
50
|
+
|
|
51
|
+
## Environment Variables
|
|
52
|
+
|
|
53
|
+
The tool uses the following environment variables:
|
|
54
|
+
- `STORAGE_TYPE`: Storage backend for migration state (`local` or `airtable`, default: `local`). See [Storage Configuration](#storage)
|
|
55
|
+
- `MPT_API_TOKEN`: Your MPT API key (required when using `MPTAPIClientMixin`)
|
|
56
|
+
- `MPT_API_BASE_URL`: The MPT API base url (required when using `MPTAPIClientMixin`)
|
|
57
|
+
- `AIRTABLE_API_KEY`: Your Airtable API key (required when using `AirtableAPIClientMixin` or when `STORAGE_TYPE=airtable`)
|
|
58
|
+
|
|
59
|
+
## Configuration
|
|
60
|
+
|
|
61
|
+
### Storage
|
|
62
|
+
|
|
63
|
+
The tool supports two storage backends: local and Airtable. By default, it uses the local storage.
|
|
64
|
+
|
|
65
|
+
Local storage is the simplest option and is suitable for development and testing. However, it is not suitable for production deployments.
|
|
66
|
+
The state is stored in a `.migrations-state.json` file in your project root.
|
|
67
|
+
|
|
68
|
+
Airtable storage is recommended for production deployments. It allows you to track migration progress across multiple deployments.
|
|
69
|
+
|
|
70
|
+
#### Local Storage
|
|
71
|
+
No additional configuration is required.
|
|
72
|
+
|
|
73
|
+
#### Airtable Storage
|
|
74
|
+
|
|
75
|
+
Airtable configuration is done via environment variables:
|
|
76
|
+
- `AIRTABLE_API_KEY`: Your Airtable API key
|
|
77
|
+
- `STORAGE_AIRTABLE_BASE_ID`: Your Airtable base ID
|
|
78
|
+
- `STORAGE_AIRTABLE_TABLE_NAME`: The name of the table to store migration state
|
|
79
|
+
|
|
80
|
+
Your Airtable table must have the following columns:
|
|
81
|
+
|
|
82
|
+
| Column Name | Field Type | Required |
|
|
83
|
+
|---------------|-----------------------------|:--------:|
|
|
84
|
+
| order_id | number | ✅ |
|
|
85
|
+
| migration_id | singleLineText | ✅ |
|
|
86
|
+
| started_at | dateTime | ❌ |
|
|
87
|
+
| applied_at | dateTime | ❌ |
|
|
88
|
+
| type | singleSelect (data, schema) | ✅ |
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
**Airtable configuration steps:**
|
|
92
|
+
1. Create a new table in your Airtable base (or use an existing one)
|
|
93
|
+
2. Add the columns listed above with the specified field types
|
|
94
|
+
3. Set the environment variables with your base ID and table name
|
|
95
|
+
|
|
96
|
+
## Usage
|
|
97
|
+
|
|
98
|
+
### Creating a New Migration
|
|
99
|
+
1. Decide the migration type (**data** or **schema**).
|
|
100
|
+
- **Data**: run after a release is deployed. Can take hours or days. Executed while MPT is running (e.g., updating product parameters, synchronizing Assets with external data)
|
|
101
|
+
- **Schema**: run before a release is deployed. Must be fast (not more than 15 min). Executed without ensuring the MPT is running (e.g., adding columns in Airtable)
|
|
102
|
+
2. Run the appropriate command:
|
|
103
|
+
```bash
|
|
104
|
+
# Data migration
|
|
105
|
+
mpt-tool migrate --new-data "migration_name"
|
|
106
|
+
```
|
|
107
|
+
```bash
|
|
108
|
+
# Schema migration
|
|
109
|
+
mpt-tool migrate --new-schema "migration_name"
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
A new file is created in `migrations/` with a timestamped prefix (e.g., `20260113180013_migration_name.py`) and a prefilled `Command` class.
|
|
113
|
+
|
|
114
|
+
order_id: timestamp prefix (e.g., `20260113180013`)
|
|
115
|
+
migration_id: user-provided name (e.g., `migration_name`)
|
|
116
|
+
file: generated file name (e.g., `20260113180013_migration_name.py`)
|
|
117
|
+
|
|
118
|
+
**Generated file structure:**
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
from mpt_tool.migration import DataBaseMigration # or SchemaBaseMigration
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
class Migration(DataBaseMigration):
|
|
125
|
+
def run(self):
|
|
126
|
+
# implement your logic here
|
|
127
|
+
pass
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
#### Using Mixins
|
|
131
|
+
You can add mixins to your migration commands to access external services:
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
from mpt_tool.migration import DataBaseMigration
|
|
135
|
+
from mpt_tool.migration.mixins import MPTAPIClientMixin, AirtableAPIClientMixin
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
class Migration(DataBaseMigration, MPTAPIClientMixin, AirtableAPIClientMixin):
|
|
139
|
+
def run(self):
|
|
140
|
+
# Access MPT API
|
|
141
|
+
agreement = self.mpt_client.commerce.agreements.get("AGR-1234-5678-9012")
|
|
142
|
+
self.log.info(f"Agreement id: {agreement.id}")
|
|
143
|
+
|
|
144
|
+
# Access Airtable
|
|
145
|
+
table = self.airtable_client.table("app_id", "table_name")
|
|
146
|
+
records = table.all()
|
|
147
|
+
|
|
148
|
+
self.log.info(f"Processed {len(records)} records")
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Running Migrations
|
|
152
|
+
- **Run all pending data migrations:**
|
|
153
|
+
```bash
|
|
154
|
+
mpt-tool migrate --data
|
|
155
|
+
```
|
|
156
|
+
- **Run all pending schema migrations:**
|
|
157
|
+
```bash
|
|
158
|
+
mpt-tool migrate --schema
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Migrations are executed in order based on their order_id (timestamp). The tool automatically:
|
|
162
|
+
- Validates the migration folder structure
|
|
163
|
+
- Skips migrations that have already been applied (applied_at is not null)
|
|
164
|
+
- Tracks execution status in the state storage (`.migrations-state.json` or Airtable table)
|
|
165
|
+
- Logs migration progress
|
|
166
|
+
- Handles errors gracefully and updates state accordingly
|
|
167
|
+
|
|
168
|
+
**Migration State File (`.migrations-state.json`):**
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
"data_example": {
|
|
172
|
+
"migration_id": "data_example",
|
|
173
|
+
"order_id": 20260113180013,
|
|
174
|
+
"started_at": "2026-01-13T18:05:20.000000",
|
|
175
|
+
"applied_at": "2026-01-13T18:05:23.123456",
|
|
176
|
+
"type": "data"
|
|
177
|
+
},
|
|
178
|
+
"schema_example": {
|
|
179
|
+
"migration_id": "schema_example",
|
|
180
|
+
"order_id": 20260214121033,
|
|
181
|
+
"started_at": null,
|
|
182
|
+
"applied_at": null,
|
|
183
|
+
"type": "schema"
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
**Migration Table (Airtable):**
|
|
188
|
+
|
|
189
|
+
| order_id | migration_id | started_at | applied_at | type |
|
|
190
|
+
|----------------|----------------|----------------------------|----------------------------|--------|
|
|
191
|
+
| 20260113180013 | data_example | 2026-01-13T18:05:20.000000 | 2026-01-13T18:05:23.123456 | data |
|
|
192
|
+
| 20260214121033 | schema_example | | | schema |
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
If a migration succeeds during execution:
|
|
196
|
+
* The started_at timestamp is recorded
|
|
197
|
+
* The applied_at timestamp is recorded
|
|
198
|
+
|
|
199
|
+
If a migration fails during execution:
|
|
200
|
+
* The started_at timestamp is recorded
|
|
201
|
+
* The applied_at field remains null
|
|
202
|
+
* The error is logged
|
|
203
|
+
* Later runs will retry the failed migration as applied_at is null, unless `--fake` is used to mark it as applied
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
### Fake Mode
|
|
207
|
+
To mark a migration as applied without running it:
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
mpt-tool migrate --fake MIGRATION_ID
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Where `MIGRATION_ID` is the filename without `order_id` and `.py` (e.g., `test1`).
|
|
214
|
+
|
|
215
|
+
**Example:**
|
|
216
|
+
- File: `20260113180013_sync_users.py`
|
|
217
|
+
- Migration ID: `sync_users`
|
|
218
|
+
|
|
219
|
+
If the migration doesn't exist in the migrations folder:
|
|
220
|
+
* An error is logged and the command exits
|
|
221
|
+
|
|
222
|
+
If the migration exists:
|
|
223
|
+
* The migration state is created if it doesn't exist yet or updated:
|
|
224
|
+
* The started_at field is set as null
|
|
225
|
+
* The applied_at timestamp is recorded
|
|
226
|
+
|
|
227
|
+
### Listing Migrations
|
|
228
|
+
To see all migrations and their status:
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
mpt-tool migrate --list
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
The output shows execution order, status, and timestamps.
|
|
235
|
+
|
|
236
|
+
The status column is derived from the persisted timestamps:
|
|
237
|
+
|
|
238
|
+
| Status | Condition |
|
|
239
|
+
|-------------|---------------------------------------------------------------|
|
|
240
|
+
| running | `started_at` is set and `applied_at` is empty |
|
|
241
|
+
| failed | `started_at` and `applied_at` are empty for an existing state |
|
|
242
|
+
| faked | `started_at` is empty and `applied_at` is set |
|
|
243
|
+
| applied | Both `started_at` and `applied_at` are set |
|
|
244
|
+
| not applied | No state entry exists for the migration file |
|
|
245
|
+
|
|
246
|
+
### Getting Help
|
|
247
|
+
Run `mpt-tool --help` to see all available commands and params:
|
|
248
|
+
```bash
|
|
249
|
+
mpt-tool --help
|
|
250
|
+
mpt-tool migrate --help
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
## Best Practices
|
|
255
|
+
|
|
256
|
+
### Migration Naming
|
|
257
|
+
- Use descriptive, snake_case names (e.g., `add_user_table`, `fix_null_emails`, `sync_agreements_from_api`)
|
|
258
|
+
- Keep names concise but meaningful
|
|
259
|
+
- Avoid generic names like `migration1`, `fix_bug`, or `update`
|
|
260
|
+
|
|
261
|
+
### Version Control
|
|
262
|
+
- Never modify a migration that has been applied in production
|
|
263
|
+
- Create a new migration to fix issues from a previous one
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
## Troubleshooting
|
|
267
|
+
|
|
268
|
+
### Common Issues
|
|
269
|
+
|
|
270
|
+
**Migrations not detected:**
|
|
271
|
+
- Ensure files are in the `migrations/` folder
|
|
272
|
+
- Verify filename follows the pattern: `<timestamp>_<migration_id>.py` (e.g., `20260121120000_migration_name.py`)
|
|
273
|
+
|
|
274
|
+
**Migration fails to run:**
|
|
275
|
+
- Review the error message in the terminal output
|
|
276
|
+
- Check your `Migration.run()` implementation for syntax errors
|
|
277
|
+
- Fix the issue and re-run the migration or use `--fake` to mark it as applied
|
|
278
|
+
|
|
279
|
+
**NOTE:** There is currently no automatic rollback mechanism. If a migration partially modifies data before failing, you must manually revert those changes or create a new migration to fix the state.
|
|
280
|
+
|
|
281
|
+
**Mixin errors (ValueError):**
|
|
282
|
+
- Verify all required environment variables are set
|
|
283
|
+
- Check variable names match exactly (case-sensitive)
|
|
284
|
+
|
|
285
|
+
**Duplicate migration IDs:**
|
|
286
|
+
- The tool prevents duplicate migration IDs automatically
|
|
287
|
+
- If you see this error, check for files with the same name in the `migrations/` folder
|
|
288
|
+
- Delete or rename the duplicate file
|
|
289
|
+
|
|
290
|
+
**Migration already applied:**
|
|
291
|
+
- If you need to re-run a migration, either:
|
|
292
|
+
- Remove its entry from the state storage (use with caution)
|
|
293
|
+
- Create a new migration with the updated logic
|
|
294
|
+
- Never modify an already-applied migration in production
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
## Development
|
|
298
|
+
|
|
299
|
+
For development purposes, please, check the Readme in the GitHub repository.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
mpt_tool/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
mpt_tool/cli.py,sha256=RQx1OUoYVSbAYTBYlgFOBGejWutKmSTY8NHzezgwjRI,2464
|
|
3
|
+
mpt_tool/config.py,sha256=X2t2Hh0OHB_4HPwaQXAwatQqgWlhjl7Rm4678Si_YaY,672
|
|
4
|
+
mpt_tool/constants.py,sha256=i3jnIAFT8XXS2Z7iw8VbyWxrmnRq3nMklMfwDgmOkxI,147
|
|
5
|
+
mpt_tool/enums.py,sha256=ElHflGP0c0Jq4PqxD3YISgdWa-hgkkd8aqD7cv5nUBc,1143
|
|
6
|
+
mpt_tool/errors.py,sha256=_u1vgUwTNj-IF7b4VJiYOkv4vgD48jMHpMYpOgGkugQ,167
|
|
7
|
+
mpt_tool/models.py,sha256=JHG6-EoVb8lVPJ-BFCTMHqPr1vdj5rERCMlB2IG8FNc,4665
|
|
8
|
+
mpt_tool/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
+
mpt_tool/renders.py,sha256=RLAQyxoLH7zCCJO62J90oAAurTMIVeyR_NNQLrb6sLk,1234
|
|
10
|
+
mpt_tool/templates.py,sha256=9-_M7Diy50D5Io0sC1Ez9ez4fNxFRMXSkIQ_7XcK95Y,308
|
|
11
|
+
mpt_tool/commands/__init__.py,sha256=UNBsxkGf4MC7tIsOHHP4leo1exBDv8MAJZY_VizZGAY,175
|
|
12
|
+
mpt_tool/commands/base.py,sha256=EfhyJm-37NMN4yu9gXFAbWuU2_7gsEKEYpKewegT0o8,752
|
|
13
|
+
mpt_tool/commands/data.py,sha256=Q_1t0QqUNrBe9h13UXkvkh12ld2EYAXVf0E_oWC36Qk,597
|
|
14
|
+
mpt_tool/commands/errors.py,sha256=yYsGZovbm-HN9dyuAcYXZhSPixwdiytUzqN18De-k3I,183
|
|
15
|
+
mpt_tool/commands/factory.py,sha256=-99SI-s_gzkxlRwbGKJ-tT84Mih8caUpd9kC6rvlLNE,1699
|
|
16
|
+
mpt_tool/commands/fake.py,sha256=O3ASK5b7Henwh9AcIujzDM84ZUzkOEuQ_HuACe_94CI,711
|
|
17
|
+
mpt_tool/commands/list.py,sha256=V_rBSfpfcRNCDry-3xvj-joWu0S3VVsmm3n4nQwueDA,874
|
|
18
|
+
mpt_tool/commands/new_data.py,sha256=Ls9S3s4eCNmkpieAlXSWNGDTlIuE3gZ-pynWGMN0sHM,820
|
|
19
|
+
mpt_tool/commands/new_schema.py,sha256=gWrP_qeIvom6x_EXwK_cfwojGzO--mKHXqtd4buHK94,826
|
|
20
|
+
mpt_tool/commands/schema.py,sha256=S6f7rFWimepDZ0v56ef3BaIRCnl3WnTyDz91CFtFZLI,631
|
|
21
|
+
mpt_tool/commands/validators.py,sha256=MWknUwEsoK-Q7ZrQCoJ8zqIZz7cIKNGjh3Ignshn2UQ,752
|
|
22
|
+
mpt_tool/managers/__init__.py,sha256=BmeIZV1Wbq5y3276kBavmDfS4RgebmX_r8QD_cs3uoE,259
|
|
23
|
+
mpt_tool/managers/encoders.py,sha256=P_619fzWxGYIBSIN5caJkXvYKrGlY8fgCuOAwFKBZlQ,356
|
|
24
|
+
mpt_tool/managers/errors.py,sha256=69j_52ezbBJYqsieZgiIVUhMcy11dJruyaKL6ZfcTP8,541
|
|
25
|
+
mpt_tool/managers/file_migration.py,sha256=0jZQFbDS1mOJCNuZkclp1u88UDtW78lHRA5xggXA1ss,4872
|
|
26
|
+
mpt_tool/managers/state/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
|
+
mpt_tool/managers/state/airtable.py,sha256=vHQyEvy1TRJgIz5LbqGwAxSh_mHHviqVvTCdpPYrzPo,3692
|
|
28
|
+
mpt_tool/managers/state/base.py,sha256=zEjnV5Qccc8vaLnfaFUaZNO0hREVRmpHyS-660UhB3k,1270
|
|
29
|
+
mpt_tool/managers/state/factory.py,sha256=lOJt132ZQoZbpiJ7HR5hOX34g8aeTZWUrT-t5B0D3-g,873
|
|
30
|
+
mpt_tool/managers/state/file.py,sha256=Y3U62Zius1T9QNtIZ2dnGiRSRFzKpG9xj-cHScK2wgI,1990
|
|
31
|
+
mpt_tool/migration/__init__.py,sha256=GHhAIHgsQ9xpIb3FB0_ERt77qZbd4iboFD2KAeJkv-A,178
|
|
32
|
+
mpt_tool/migration/base.py,sha256=gbvfJwLnvQsOG_gWXTMGIvkxwrEFTKFAPovZeAz89jA,571
|
|
33
|
+
mpt_tool/migration/data_base.py,sha256=EZIAXhriXr61Gu-6ZbRbvhAnRv5zysQDX9Gco3BNP6E,243
|
|
34
|
+
mpt_tool/migration/schema_base.py,sha256=u3XH-OKii1p4jwMjdI92w5Q71YZ07s2FI4bDDC_FtfQ,249
|
|
35
|
+
mpt_tool/migration/mixins/__init__.py,sha256=qvWJfFqTzphAgR5vrTC1qzzWvrDTWKhtiWGpWS4kq1I,203
|
|
36
|
+
mpt_tool/migration/mixins/airtable_client.py,sha256=1Al-JcUI1svZV8L9nuxzvP9tZGqvfOBVMwPZ904Hfp4,805
|
|
37
|
+
mpt_tool/migration/mixins/mpt_client.py,sha256=oUQUi0usC85Z9aCzaFM8UzRrxnGGrcf3cj0DfYzm24E,909
|
|
38
|
+
mpt_tool/use_cases/__init__.py,sha256=27zQVYF4GIVufBAwuQlf-ESSJAjPotGxr9kwho3vyzI,398
|
|
39
|
+
mpt_tool/use_cases/apply_migration.py,sha256=nZXdESTQYKGbBbfA2CoKb_d_x8K8bMker7-DJ1rvklc,1745
|
|
40
|
+
mpt_tool/use_cases/errors.py,sha256=Rn_5P9XF5sELX7IXlqdX7I47zsD1JbadzLMYMa_ruP4,343
|
|
41
|
+
mpt_tool/use_cases/list_migrations.py,sha256=a4Otx6IL5EkqU-iwWjYEaFdD8eR4Zha7GDmQMRjVhuw,1427
|
|
42
|
+
mpt_tool/use_cases/new_migration.py,sha256=pNHrOamGPupyGb7s9_P1B0-r_ooNDqcYpU0oiGNt2HU,860
|
|
43
|
+
mpt_tool/use_cases/run_migrations.py,sha256=iHGnUEuUKRWo_ZgvUQFfsUIaAtCAZvWW0pbf60j8dzM,3798
|
|
44
|
+
mpt_tool-5.0.0.dist-info/METADATA,sha256=4im9i9bXu5JWiUTAuO26r_wYap48UzqXjaBBLEjqMPQ,10111
|
|
45
|
+
mpt_tool-5.0.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
46
|
+
mpt_tool-5.0.0.dist-info/entry_points.txt,sha256=ouNlQh2WYlerppVMgMkkTQKoEDlgAczOhCMhDQMhu-0,47
|
|
47
|
+
mpt_tool-5.0.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
48
|
+
mpt_tool-5.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|