40 lines
1.2 KiB
Markdown
40 lines
1.2 KiB
Markdown
|
|
# Migration Framework
|
||
|
|
This script provides a easier, faster and safer way to do migration on the manifests.
|
||
|
|
|
||
|
|
## How to use
|
||
|
|
1. Create a new file and implement the `AbstractMigration` class.
|
||
|
|
2. Implement `migrate` method. This method will be called when the migration is executed.
|
||
|
|
3. Override `filter` method. Use this function if you do not want to run the migration on all manifests.
|
||
|
|
4. Run your class using this method:
|
||
|
|
```python
|
||
|
|
async def main():
|
||
|
|
migration = CustomMigration(
|
||
|
|
"https://deployment-portal-backend.np.navi-tech.in",
|
||
|
|
"<x-auth-token>",
|
||
|
|
)
|
||
|
|
await migration.run()
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
asyncio.run(main())
|
||
|
|
```
|
||
|
|
|
||
|
|
Refer to [example_migration.py](example_migration.py) for a sample migration.
|
||
|
|
|
||
|
|
## Set up environment
|
||
|
|
1. It is advisable to use a virtual environment to run the migration script. To set up the environment, run the following commands:
|
||
|
|
```bash
|
||
|
|
cd scripts/_migration_framework
|
||
|
|
python3 -m venv venv
|
||
|
|
source venv/bin/activate
|
||
|
|
pip install -r requirements.txt
|
||
|
|
```
|
||
|
|
2. Run the migration script
|
||
|
|
```bash
|
||
|
|
python example.py
|
||
|
|
```
|
||
|
|
3. To deactivate the virtual environment, run the following command:
|
||
|
|
```bash
|
||
|
|
deactivate
|
||
|
|
```
|