News for hackers. Stuff that matters.
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?