News for hackers. Stuff that matters.
Re:Better Database Migrations in Postgres by misframer on Tuesday September 12, 2017 @11:46PM (#15235369)
strong_migrations looks like a really useful tool. Are there similar ones for languages/frameworks besides Ruby/Rails?
Re:Better Database Migrations in Postgres by sandGorgon on Wednesday September 13, 2017 @01:02AM (#15235693)
Alembic is a standalone tool written in Python. Having spent years on rails migrations and then using Alembic, I can say that alembic is really brilliant. It behaves like git - it has a branching and merge model for Migrations (in case multiple people work on it simultaneously).
Re:Better Database Migrations in Postgres by anentropic on Wednesday September 13, 2017 @06:54AM (#15237088)
but it seems like the USP of strong_migrations is to recognise 'dangerous' operations in a migration and warn you about them so that you can rewrite it as a safer migration

Does alembic have anything similar? this would be useful for Python projects

Re:Better Database Migrations in Postgres by robertlagrant on Wednesday September 13, 2017 @06:03AM (#15236895)
Alembic is amazing, but AFAIK only works with its author's (world-beating) ORM, SQLAlchemy. I didn't think it was a general-purpose database change tool.
Re:Better Database Migrations in Postgres by sandGorgon on Wednesday September 13, 2017 @06:15AM (#15236943)
We use it standalone for our nodejs code. It does pull-in SQL alchemy, but who cares. I think what you are really asking is this - We don't autogenerate migrations from models, we write them explicitly.

There is nothing even close enough in the nodejs world and we wanted to manage our dB properly.

Incidentally, three other nodejs startups that I told this to, also started using Alembic for their migrations.

Re:Better Database Migrations in Postgres by aidos on Wednesday September 13, 2017 @07:32AM (#15237249)
You could potentially use SQLA's ability to reflect your db to create the models either to get you started, or maybe in an automated fashion. Im sure there are loads of corner cases where it wouldn't work.

We're happy users of alembic. In general we use it to do the initial grunt work and then manually edit the migrations / split into phases ourselves. For some stuff that Alembic doesn't handle very well (like check constraints) we've extended Alembic to handle those automatically in the way we like.

Re:Better Database Migrations in Postgres by LyndsySimon on Wednesday September 13, 2017 @09:54AM (#15238240)
I don't know Alembic well enough to know what features of SQLAlchemy it requires, but I do know that SQLAlchemy consists of quite a bit more than just the ORM features. Perhaps Alembic is using it at a lower level, and can be used with any (or no) ORM layer?
Re:Better Database Migrations in Postgres by neeleshs on Tuesday September 12, 2017 @11:49PM (#15235379)
For JVM languages, Flyway is quite popular (flywaydb.org) Django (python) has a builtin migration tool
Re:Better Database Migrations in Postgres by craigkerstiens on Tuesday September 12, 2017 @11:51PM (#15235391)
Original author here, thanks for sharing it. Will update the post to add it to the list of good tools.
Re:Better Database Migrations in Postgres by nblumhardt on Wednesday September 13, 2017 @12:01AM (#15235430)
Another x-plat CLI option is Piggy - https://github.com/datalust/piggy - a side-project still early days of development, but may be interesting for the lack of (e.g. JVM) dependencies. It's a self-contained binary for Win/Mac/Linux.

DbUp, upon which Piggy is based, is a popular option in the .NET space: https://dbup.github.io/.

(Neither attempt the protections that I think strong_migrations is offering - TIL!)

Re:Better Database Migrations in Postgres by fulafel on Tuesday September 12, 2017 @11:53PM (#15235405)
It works well as a command line tool, so not even restricted to JVM languages.

One strong point of Flyway, besides being "just SQL", is the repeatable migrations, you can update your stored procedures, views and table documentation in the same version controlled source files without making a new copy in a new migration file for each change.

Re:Better Database Migrations in Postgres by iaabtpbtpnn on Wednesday September 13, 2017 @02:10AM (#15235940)
Oooh I use Flyway but did not know about this feature! It solves a big problem for me, thank you for mentioning it! :)
Re:Better Database Migrations in Postgres by oneweekwonder on Wednesday September 13, 2017 @01:17AM (#15235739)