{"id":13468111,"url":"https://github.com/abe-winter/automigrate","last_synced_at":"2025-12-30T08:32:42.025Z","repository":{"id":45622619,"uuid":"178510839","full_name":"abe-winter/automigrate","owner":"abe-winter","description":"version your SQL schemas with git + automatically migrate them","archived":true,"fork":false,"pushed_at":"2021-12-04T06:55:14.000Z","size":240,"stargazers_count":334,"open_issues_count":7,"forks_count":4,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-11T06:54:34.421Z","etag":null,"topics":["declarative","migration","sql"],"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/abe-winter.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-30T04:23:12.000Z","updated_at":"2025-03-03T16:20:31.000Z","dependencies_parsed_at":"2022-09-26T17:11:19.740Z","dependency_job_id":null,"html_url":"https://github.com/abe-winter/automigrate","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abe-winter%2Fautomigrate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abe-winter%2Fautomigrate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abe-winter%2Fautomigrate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abe-winter%2Fautomigrate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abe-winter","download_url":"https://codeload.github.com/abe-winter/automigrate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245585027,"owners_count":20639663,"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":["declarative","migration","sql"],"created_at":"2024-07-31T15:01:05.660Z","updated_at":"2025-12-13T22:02:59.179Z","avatar_url":"https://github.com/abe-winter.png","language":"Python","readme":"# automigrate\n\nAutomigrate is a command-line tool for ORM-less SQL migrations.\nUnlike other migration tools, it uses git history to do diffs on `create table` statements instead of storing the migration history in a folder somewhere.\n\n* [How is this different](#how-is-this-different)\n* [Usage](#usage)\n* [Advanced features](#advanced-features)\n\n## How is this different\n\nThis tool uses git history to infer database migrations, and uses git SHAs to version production databases.\n\nOther schema migration tools typically work by diffing ORM definitions against a live database (which can be your local DB).\nOften these diffs are then checked into a folder in your project repo.\n\nSeriously, all you have to do is maintain a file like this:\n\n```sql\n-- schema.sql\ncreate table whatever (\n  userid uuid primary key,\n  age_at_birth int default 0\n);\n```\n\nAnd when you add a field to the create table statement, automig figures out the 'alter table'.\n\n## Usage\n\nIf you're using postgres:\n\n```bash\npip install automig[postgres]\n# set an environment var with postgres connection details\nexport AUTOMIG_CON=postgresql://postgres:$PGPASSWORD@host\n# initialize the postgres DB to schema/*.sql -- do this once to create a DB\nautomig_pg --glob 'schema/*.sql' init\n# update your DB to whatever sha is at git HEAD -- do this whenever your schema changes\nautomig_pg --glob 'schema/*.sql' update\n# do a dry-run, show the output without applying it\nautomig_pg --preview --glob 'schema/*.sql' update\n```\n\nIf you're using another database, you can get the raw SQL for these actions by using the `automig` tool instead of `automig_pg`. (docs coming soon).\n\nPostgres is the primary database I test on, with sqlite support secondary.\n\n## Advanced features\n\n* [Instructions for doing kube-native migrations](./kube) are in the `kube` folder.\n* Lambda support: you'll need to bundle a binary version of git that's compatible with amazonlinux. Post an issue if you need help with this.\n* You can skip over bad diffs using `--opaque` mode, docs coming soon\n* You can specify manual overrides for erroring diffs, or skip over whole shas, by using [.manualmig.yml file](./.manualmig.yml). docs coming soon but in the meantime look inside that file for an example.\n* Convert an existing DB to use automig -- please post a github issue if you have this issue and I'll add instructions\n\n### Generate ORM definitions from SQL\n\nExperimental sqlalchemy generator in sa_harness.py. Try it out with:\n\n```bash\npython -m automig.lib.sa_harness 'test/schema/*.sql'\n```\n","funding_links":[],"categories":["Python","sql"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabe-winter%2Fautomigrate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabe-winter%2Fautomigrate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabe-winter%2Fautomigrate/lists"}