Skip to content

Schniz/migrate.sh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 

Repository files navigation

migrate.sh

simple postgresql migration system in bash

I wrote it for some Python project I worked on and wanted to have ActiveRecord-style migrations. Alembic was too complex and I felt that creating a new Rails project for this job is too much. And I wanted that it'd be super fast to use the generated schema with CI services. Since SQL is cool and Bash is super fast - that's what we've got:

  • Small bash file, so it's fast
  • Uses transactions for DDLs (per migration)
  • Stores schema SQL file so you can load schema just by psqling in CI

Download

curl -L https://raw.githubusercontent.com/Schniz/migrate.sh/master/migrate.sh > migrate.sh

Update

Same as download 💥

Usage

Create a migration

./migrate.sh new my_migration_name

creates a migration file in db/migrations/TIMESTAMP_my_migration_name.sql

Apply migrations

DATABASE_URL=postgresql://... ./migrate.sh up

Load schema

DATABASE_URL=postgresql://... ./migrate.sh schema:load

loads a schema from db/schema.sql to the database

Dump schema

DATABASE_URL=postgresql://... ./migrate.sh schema:dump

dumps the database schema to db/schema.sql

Development

It is currently works on OSX, which is my main machine. Contributions are welcome!

About

simple postgresql migration system in bash

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages