Skip to main content

migrate-code

PyPI - Version PyPI - Python Version


Table of Contents

Links

Installation

pip install migrate-code

Quickstart

Migration stages will be converted into commits when the upgrade is applied. The migration.py file should define a Migration variable either called m or migration.

# migration.py

from migrate_code import Migration, get_repo_root

m = Migration("Demonstrate basic usage")

@m.add_stage(1, "Create a new file")
def stage_1():
    (get_repo_root() / "new_file.txt").write_text("Hello world")


@m.add_stage(2, "Create another file")
def stage_2():
    (get_repo_root() / "another_file.txt").write_text("Hello another world")


@m.add_stage("1.1", "Modify the first file")
def stage_1_1():
    (get_repo_root() / "new_file.txt").write_text("Hello world, again")

Now it is easy to create and reset commits:

$ git init
$ git add migration.py
$ git commit -m "Add migration.py"
$ migrate-code log
  ------- (2) Create another file
  ------- (1.1) Modify the first file
  ------- (1) Create a new file
$ migrate-code current
None
$ migrate-code upgrade
Running migration 1: Create a new file
Running migration 1.1: Modify the first file
Running migration 2: Create another file
$ git log --oneline
5041191 (HEAD -> master) Create another file
92012af Modify the first file
d4d0611 Create a new file
78438e2 Add migration.py
$ migrate-code log
* 5041191 (2) Create another file
  92012af (1.1) Modify the first file
  d4d0611 (1) Create a new file
$ migrate-code current
2
$ migrate-code reset
Resetting migration 2: Create another file
Resetting migration 1.1: Modify the first file
Resetting migration 1: Create a new file
$ git log --oneline
78438e2 (HEAD -> master) Add migration.py
$ migrate-code log
  ------- (2) Create another file
  ------- (1.1) Modify the first file
  ------- (1) Create a new file
$ migrate-code upgrade --stage 1.1
Running migration 1: Create a new file
Running migration 1.1: Modify the first file
$ git log --oneline
7b65210 (HEAD -> master) Modify the first file
a7c1027 Create a new file
78438e2 Add migration.py
$ migrate-code log
  ------- (2) Create another file
* 7b65210 (1.1) Modify the first file
  a7c1027 (1) Create a new file

License

migrate-code is distributed under the terms of the MIT license.

Metadata

Release files for migrate-code 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for migrate-code 1.0.0
File Size Uploaded
migrate_code-1.0.0.tar.gz 9.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for migrate-code 1.0.0
File Interpreter ABI Platform
migrate_code-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.9 kB

Release files / migrate_code-1.0.0.tar.gz

Download URL migrate_code-1.0.0.tar.gz
Size 9.5 kB
Tags Source
SHA-256 checksum
How to use checksums
eb865d3338442ab15a3cf05c470c3b01851fb61653db45caeaa3d8eeb382918c
BLAKE2b-256 checksum
How to use checksums
9adcc0d813a205a7a655f342b48b01c0e250c5535d79c8beecfcde5975683aa7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.23.0

Release files / migrate_code-1.0.0-py3-none-any.whl

Download URL migrate_code-1.0.0-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c89bc710cc064519023a652ad5f90714c7929af25e8ab8cf1085f157276d87b1
BLAKE2b-256 checksum
How to use checksums
41dc2c58eaa4236b736e699ff3b5b0665081f9f7412816d8cfd0ae7e6bbf2e57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.23.0

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page