{"id":22974351,"url":"https://github.com/diversen/python-mysql-migrations","last_synced_at":"2025-04-02T07:25:11.552Z","repository":{"id":138270944,"uuid":"577732356","full_name":"diversen/python-mysql-migrations","owner":"diversen","description":"Simple python migrations for MySQL without using ORM","archived":false,"fork":false,"pushed_at":"2022-12-14T09:34:03.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-07T22:28:35.768Z","etag":null,"topics":["mysql-migrations","python-mysql-migrations"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/diversen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-13T11:59:39.000Z","updated_at":"2023-03-17T13:32:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"cdc236d7-e611-4bec-86ac-383a8dd5e84a","html_url":"https://github.com/diversen/python-mysql-migrations","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diversen%2Fpython-mysql-migrations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diversen%2Fpython-mysql-migrations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diversen%2Fpython-mysql-migrations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diversen%2Fpython-mysql-migrations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/diversen","download_url":"https://codeload.github.com/diversen/python-mysql-migrations/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246771767,"owners_count":20831099,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mysql-migrations","python-mysql-migrations"],"created_at":"2024-12-15T00:00:36.863Z","updated_at":"2025-04-02T07:25:11.547Z","avatar_url":"https://github.com/diversen.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# python mysql migration\n\nSimple Python MySQL migration tool.\n\nIt executes files with SQL statements in e.g. `migrations/up` and `migrations/down` directories. \n\nThe main usage is probably if you don't use a ORM, but query the MySQL database directly - maybe using `mysql.connector`.\n\n## Install mysql-migration\n\n    pip install git+https://github.com/diversen/python-mysql-migrations\n\nOr using a tag:\n\n    pip install git+https://github.com/diversen/python-mysql-migrations@v0.0.2\n\n## Create migrations dir\n\n    mkdir -p migrations/up migrations/down\n\nAdd SQL files into `migrations/up` and `migrations/down` directories, which will then be executed.\n\nE.g.: \n    \n    migrations/up/0001.sql\n    migrations/up/0002.sql\n    migrations/down/0001.sql\n    migrations/down/0002.sql\n\n## Usage\n\n```python\nfrom mysql_migrations import MySQLMigrations\n\n# The 'migration_file' should be in a .gitignore file if using git\n# This file holds the current version of the database\nm = MySQLMigrations(migration_dir='migrations', migration_file='.migration')\nm.connect(host='localhost', user='root', password='password', database='mysql_migration_test')\n\n# Executes 0001.sql and 0002.sql up files. The .migration version is 2\nm.migrate_up(2) \n\n# Excutes 0002.sql down. Now version the .migration version is 1\nm.migrate_down(1) \n\n# Executes 0002.sql up. The version .migration is 2\nm.migrate_up()\n\n# Executes 0002.sql and then 0001.sql down files, The .migration version is 0\nm.migrate_down() \n\n# Get current version\nm.get_current_version() # -\u003e 0\n\n```\n\n## Tests\n\nThe test uses a docker container with MySQL and a database named 'mysql_migration_test'.\n    \nThese are the connection parameters:\n\n```python\nm = MySQLMigrations(migration_dir='migrations', migration_file='.migration')\nm.connect(host='localhost', user='root', password='password', database='mysql_migration_test')\n```\n\nTo run the tests:\n\n    python -m unittest discover -s tests\n    \n\n## License\n\n[MIT](LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiversen%2Fpython-mysql-migrations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiversen%2Fpython-mysql-migrations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiversen%2Fpython-mysql-migrations/lists"}