All Projects → abe-winter → Automigrate

abe-winter / Automigrate

Licence: mit
version your SQL schemas with git + automatically migrate them

Programming Languages

python
139335 projects - #7 most used programming language
declarative
70 projects

Projects that are alternatives of or similar to Automigrate

Migrate
Database migrations. CLI and Golang library.
Stars: ✭ 7,712 (+2325.16%)
Mutual labels:  sql, migration
Evolve
Database migration tool for .NET and .NET Core projects. Inspired by Flyway.
Stars: ✭ 477 (+50%)
Mutual labels:  sql, migration
Migrate
Database migrations. CLI and Golang library.
Stars: ✭ 2,315 (+627.99%)
Mutual labels:  sql, migration
Node Sqlite
SQLite client for Node.js applications with SQL-based migrations API written in Typescript
Stars: ✭ 642 (+101.89%)
Mutual labels:  sql, migration
Node Pg Migrate
Node.js database migration management for Postgresql
Stars: ✭ 838 (+163.52%)
Mutual labels:  sql, migration
Goose
A database migration tool. Supports SQL migrations and Go functions.
Stars: ✭ 2,112 (+564.15%)
Mutual labels:  sql, migration
Fluentmigrator
Fluent migrations framework for .NET
Stars: ✭ 2,636 (+728.93%)
Mutual labels:  sql, migration
Requery
requery - modern SQL based query & persistence for Java / Kotlin / Android
Stars: ✭ 3,071 (+865.72%)
Mutual labels:  sql
Sqls
SQL language server written in Go.
Stars: ✭ 301 (-5.35%)
Mutual labels:  sql
Javacodeaudit
Getting started with java code auditing 代码审计入门的小项目
Stars: ✭ 289 (-9.12%)
Mutual labels:  sql
Text2sql Data
A collection of datasets that pair questions with SQL queries.
Stars: ✭ 287 (-9.75%)
Mutual labels:  sql
Agilebill
Open source billing and invoicing
Stars: ✭ 292 (-8.18%)
Mutual labels:  sql
Firesql
Query Firestore using SQL syntax
Stars: ✭ 304 (-4.4%)
Mutual labels:  sql
Codecademy Exercise Answers
🎓 Codecademy.com exercise answers
Stars: ✭ 291 (-8.49%)
Mutual labels:  sql
Themis
数据库审核平台
Stars: ✭ 313 (-1.57%)
Mutual labels:  sql
Crate
CrateDB is a distributed SQL database that makes it simple to store and analyze massive amounts of data in real-time.
Stars: ✭ 3,254 (+923.27%)
Mutual labels:  sql
Mongo Sql
An extensible SQL generation library for JavaScript with a focus on introspectibility
Stars: ✭ 314 (-1.26%)
Mutual labels:  sql
Ansible Role Postgresql
Ansible Role - PostgreSQL
Stars: ✭ 310 (-2.52%)
Mutual labels:  sql
Catena
Catena is a distributed database based on a blockchain, accessible using SQL.
Stars: ✭ 302 (-5.03%)
Mutual labels:  sql
Gowapt
Go Web Application Penetration Test
Stars: ✭ 300 (-5.66%)
Mutual labels:  sql

automigrate

Automigrate is a command-line tool for SQL migrations. Unlike other migration tools, it uses git history to do diffs on create table statements instead of storing the migration history in a folder somewhere.

How is this different

This tool uses git history to infer database migrations, and uses git SHAs to version production databases.

Other schema migration tools typically work by diffing ORM definitions against a live database (which can be your local DB). Often these diffs are then checked into a folder in your project repo.

Seriously, all you have to do is maintain a file like this:

-- schema.sql
create table whatever (
  userid uuid primary key,
  age_at_birth int default 0
);

And when you add a field to the create table statement, automig figures out the 'alter table'.

Usage

If you're using postgres:

pip install automig[postgres]
# set an environment var with postgres connection details
export AUTOMIG_CON=postgresql://postgres:$PGPASSWORD@host
# initialize the postgres DB to schema/*.sql -- do this once to create a DB
automig_pg --glob 'schema/*.sql' init
# update your DB to whatever sha is at git HEAD -- do this whenever your schema changes
automig_pg --glob 'schema/*.sql' update
# do a dry-run, show the output without applying it
automig_pg --preview --glob 'schema/*.sql' update

If 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).

Postgres is the primary database I test on, with sqlite support secondary.

Advanced features

  • Instructions for doing kube-native migrations are in the kube folder.
  • 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.
  • You can skip over bad diffs using --opaque mode, docs coming soon
  • You can specify manual overrides for erroring diffs, or skip over whole shas, by using .manualmig.yml file. docs coming soon but in the meantime look inside that file for an example.
  • Convert an existing DB to use automig -- please post a github issue if you have this issue and I'll add instructions

Generate ORM definitions from SQL

Experimental sqlalchemy generator in sa_harness.py. Try it out with:

python -m automig.lib.sa_harness 'test/schema/*.sql'
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].