{"id":17044778,"url":"https://github.com/keredson/peewee-db-evolve","last_synced_at":"2025-04-07T05:15:14.032Z","repository":{"id":54147918,"uuid":"66296066","full_name":"keredson/peewee-db-evolve","owner":"keredson","description":"Automatic migrations for the Peewee ORM.","archived":false,"fork":false,"pushed_at":"2023-04-03T01:03:26.000Z","size":148,"stargazers_count":128,"open_issues_count":13,"forks_count":26,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-31T04:07:46.979Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/keredson.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":"2016-08-22T18:03:40.000Z","updated_at":"2024-11-14T17:22:54.000Z","dependencies_parsed_at":"2024-06-19T00:26:04.584Z","dependency_job_id":"fd65d548-a720-4884-993b-d34ab96a6c37","html_url":"https://github.com/keredson/peewee-db-evolve","commit_stats":{"total_commits":129,"total_committers":9,"mean_commits":"14.333333333333334","dds":0.5271317829457365,"last_synced_commit":"bc3a2a219194b5d0ba7fb9a764b69af8cc3bcd97"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keredson%2Fpeewee-db-evolve","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keredson%2Fpeewee-db-evolve/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keredson%2Fpeewee-db-evolve/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keredson%2Fpeewee-db-evolve/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keredson","download_url":"https://codeload.github.com/keredson/peewee-db-evolve/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247595335,"owners_count":20963943,"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":[],"created_at":"2024-10-14T09:35:29.340Z","updated_at":"2025-04-07T05:15:14.007Z","avatar_url":"https://github.com/keredson.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://cloud.githubusercontent.com/assets/2049665/17952702/c04e0846-6a32-11e6-8797-60ba50fc0fa6.png\" style='width:100%'\u003e\n\n[![Build Status](https://travis-ci.org/keredson/peewee-db-evolve.svg?branch=master)](https://travis-ci.org/keredson/peewee-db-evolve)\n\nPeewee DB Evolve\n================\n\nDiffs your models against your database, and outputs SQL to (non-destructively) update your schema.\n\nThink of it as `db.create_tables()` on steriods (which doesn't drop your database).\n\nYou can also think of it as schema migrations, without having to actually write the migrations.\n\nQuick Start\n-----------\n\n1. Run: `sudo pip install peewee-db-evolve`\n2. Add `import peeweedbevolve` anywhere before your models are defined.\n3. Run `db.evolve()` where you would have normally run `db.create_tables()`, and enjoy!\n\nFunctions\n---------\n\nThe function `evolve(db, interactive=True, ignore_tables=None, schema=None)` is injected into Peewee's database object.\n\n- `interactive` if true will display the proposed changes and prompt you to confirm.  If false will apply them automatically.\n- `ignore_tables` takes a list of tables you don't want to evolve for whatever reason.\n- `schema` will evolve schemas other than your default schema.\n\nUsage\n-----\n\nWrite your models as you normall would.  This project will diff the schema defined by your models from the schema\ndefined in your database, and offer schema changes for your approval.\n\nRenaming columns can be achieved by using the `aka` keyword injected into Peewee's column definition.  For example, if you have:\n\n```python\nname = pw.CharField(null=True)\n```\nAnd you want to rename it to `full_name`, change your model definition to read:\n```python\nfull_name = pw.CharField(null=True, aka='name')\n```\nThis will generate a RENAME operation instead of a delete then an add.\n\nThe parameter `aka` can be either a string or a list (if you have multiple previous names).  Once it's evolved you can\nremove it or leave it as you see fit.\n\n\nExample\n-------\nSee our [Hello World](https://github.com/keredson/peewee-db-evolve/tree/master/examples/hello_world) example.\n\n![image](https://cloud.githubusercontent.com/assets/2049665/17993037/1d1c8cf2-6b12-11e6-8591-cd11eb263938.png)\n\n\nSupported Databases\n-------------------\n\n- PostgreSQL\n- MySQL\n\nFrequently Asked Questions\n--------------------------\n\n*Does this work with existing projects, or only with new projects?*\n\nThis works very well with existing projects.  If your API only works with new projects, you're probably doing it wrong.\n\n*Don't you give up control by not writing your own migrations?*\n\nManaging your schema by writing your own migrations is kind of like managing your source code by writing your own `patch` files in addition to writing your actual code.  A well vetted `diff` tool is going to be better and faster at it than you.\n\n*How old / well vetted is this tool?*\n\nThis project has been in production use since August 2016.  (We switched to Peewee as an ORM.)  But it's a style of schema management I've been using for ~10 years now.\n\n*How can I prevent `peewee-db-evolve` from evolving a specific table or class?*\n\nIn the class' `Meta` class, add `evolve = False` and `peewee-db-evolve` will ignore it.  If you don't have a class for a specific table, just make a do-nothing dummy class for it.  Or you can pass in any iterable into the `ignore_tables` kwarg of `evolve()`.\n\nTests\n-----\n\nHow to run:\n\n```bash\n$ python3 test.py\n..................................................................................................\n----------------------------------------------------------------------\nRan 110 tests in 49.408s\n\nOK\n```\n\nIf you get this:\n```\nEERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)\n```\n\nSomething like this should get you going:\n```bash\n$ sudo apt install mysql-server\n[...]\n\n$ sudo cat /etc/mysql/debian.cnf\n# Automatically generated for Debian scripts. DO NOT TOUCH!\n[client]\nhost     = localhost\nuser     = debian-sys-maint\npassword = XXXXXXXXXXXXX\nsocket   = /var/run/mysqld/mysqld.sock\n\n$ mysql -u debian-sys-maint -p\nEnter password: \nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nmysql\u003e CREATE USER 'derek'@'localhost';\nmysql\u003e GRANT ALL ON *.* TO 'derek'@'localhost';\nmysql\u003e flush privileges;\n```\n\nObviously change `derek` to your username.\n\n**WARNING:** This creates an unauthenticated mysql user on your local box.  Don't do this if you have anything important in your local MySQL instance!\n\n\u003cimg src=\"https://travis-ci.org/keredson/peewee-db-evolve.svg\"\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeredson%2Fpeewee-db-evolve","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeredson%2Fpeewee-db-evolve","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeredson%2Fpeewee-db-evolve/lists"}