You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/PROJECT_DESCRIPTION.md
+37-4Lines changed: 37 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,12 +7,16 @@ mpt-tool is a command-line utility to scaffold, run, and audit migrations for MP
7
7
```bash
8
8
pip install mpt-tool
9
9
```
10
-
2. **Create your first migration:**
10
+
2. **Initialize the migration tool:**
11
+
```bash
12
+
mpt-tool migrate --init
13
+
```
14
+
3. **Create your first migration:**
11
15
```bash
12
16
mpt-tool migrate --new-data sync_users
13
17
```
14
-
3. **Edit the generated file in the migrations/ folder**
15
-
4. **Run all pending migrations**
18
+
4. **Edit the generated file in the migrations/ folder**
19
+
5. **Run all pending data migrations**
16
20
```bash
17
21
mpt-tool migrate --data
18
22
```
@@ -32,7 +36,7 @@ Install with pip or your favorite PyPI package manager:
32
36
## Prerequisites
33
37
34
38
- Python 3.12+ in your environment
35
-
- A `migrations/` folder in your project (it will be created automatically the first timeyou create a migration)
39
+
- A `migrations/` folder in your project (created automatically with `--init` or when you create your first migration)
36
40
- Environment variables. See [Environment Variables](#environment-variables) for details.
37
41
38
42
## Environment Variables
@@ -80,6 +84,27 @@ Your Airtable table must have the following columns:
80
84
2. Add the columns listed above with the specified field types
81
85
3. Set the environment variables with your base ID and table name
82
86
87
+
## Initialization
88
+
89
+
Before using the migration tool for the first time, you should initialize it. This creates the necessary resources:
90
+
91
+
```bash
92
+
mpt-tool migrate --init
93
+
```
94
+
95
+
This command creates:
96
+
- The `migrations/` folder in your project root (if it doesn't exist)
97
+
- The state storage:
98
+
- For **local storage**: creates `.migrations-state.json` file
99
+
- For **Airtable storage**: creates the table in Airtable with the required schema
100
+
101
+
**When to use `--init`:**
102
+
- First time setting up the tool in a project
103
+
- When switching from local to Airtable storage (or vice versa)
104
+
- When you need to recreate the state storage
105
+
106
+
**Note:** If the state storage already exists, the command will fail with an error message. This prevents accidental data loss. If you need to reinitialize, manually delete the existing state file or table first.
107
+
83
108
## Usage
84
109
85
110
### Creating a New Migration
@@ -281,6 +306,14 @@ Run `mpt-tool --help` to see all available commands and params:
281
306
282
307
### Common Issues
283
308
309
+
**Initialization fails - state already exists:**
310
+
- Error: "Cannot initialize - State file already exists" (local storage) or similar for Airtable
311
+
- Cause: The state storage has already been initialized
312
+
- Solution: This is intentional to prevent data loss. If you need to reinitialize:
313
+
- For local storage: delete `.migrations-state.json` manually
314
+
- For Airtable: delete the table manually or use a different table name
315
+
- Only reinitialize if you're certain you want to start fresh
316
+
284
317
**Migrations not detected:**
285
318
- Ensure files are in the `migrations/` folder
286
319
- Verify filename follows the pattern: `<timestamp>_<migration_id>.py` (e.g., `20260121120000_migration_name.py`)
0 commit comments