I really just want a deterministic (or sync-based) migration tool. The only two I'm aware of are Innovartis DBGhost and RedGate SQL Compare (though RedGate requires a license everywhere it runs, whereas DBGhost only requires a license to compile the package). This stems from my work years ago with databases in on-premise products. Customers would modify the database schema, causing migration "up" scripts to fail, and…
(We should coin a term for this. I propose: "idempotent database updates".) I'm also a strong proponent of idempotent database updates, and prefer those over classic migrations wherever possible. Some experience from PostgreSQL (with several years of experience in various applications): While this approach works pretty well for idempotent changes such as "add column if not exists", it is more tricky when data content…
Better Database Migrations in Postgres
71–80 of 89 posts
Re: Better Database Migrations in Postgres
#72[1] http://www.databasesoup.com/2015/08/lock-polling-script-for-...
Re: Better Database Migrations in Postgres
#73What's everyone favorite library for doing Postgres migrations using node? I'm using knex.js and still doing migrations mostly by hand.
It is glorious. I write a nice DSL called SQL for my database and there are never any surprises. If I want to write brittle migrations, idempotent migrations, transactional migrations, or data migrations, those are all on me. Anything more than this leads to needless debugging the tools and has never resulted in more clear or concise code.
Re: Better Database Migrations in Postgres
#74Earlier quoted context omitted.
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).
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
#75I really just want a deterministic (or sync-based) migration tool. The only two I'm aware of are Innovartis DBGhost and RedGate SQL Compare (though RedGate requires a license everywhere it runs, whereas DBGhost only requires a license to compile the package). This stems from my work years ago with databases in on-premise products. Customers would modify the database schema, causing migration "up" scripts to fail, and…
We used thisbat a previous job. I loved it. https://github.com/dbsteward/dbsteward You define you're schema and it figures out what tonsonbased onbyour current schema.
Re: Better Database Migrations in Postgres
#76https://www.braintreepayments.com/blog/safe-operations-for-h...
Has anyone been collating large-scale SQL best practices into a book or similar? I've found high-level overviews such as this https://github.com/donnemartin/system-design-primer, but lacks specifics to scaling SQL...I've only seen disparate blog posts like the one above.
Re: Better Database Migrations in Postgres
#77Earlier quoted context omitted.
We used thisbat a previous job. I loved it. https://github.com/dbsteward/dbsteward You define you're schema and it figures out what tonsonbased onbyour current schema.
Can it handle stored procs / UDFs? Was unable to find this in the docs...
Re: Better Database Migrations in Postgres
#78What's the case where adding a JSON column causes downtime with Postgres?
What do you mean?
Re: Better Database Migrations in Postgres
#79Earlier quoted context omitted.
(We should coin a term for this. I propose: "idempotent database updates".) I'm also a strong proponent of idempotent database updates, and prefer those over classic migrations wherever possible. Some experience from PostgreSQL (with several years of experience in various applications): While this approach works pretty well for idempotent changes such as "add column if not exists", it is more tricky when data content…
One caveat regarding "Always put each migration into a database transaction": I've found that for very large database tables on a live system, it becomes impractical to e.g. create a new index inside a transaction, because the entire table would need to be locked for the duration of the operation.
https://www.postgresql.org/docs/current/static/mvcc-intro.ht...
Re: Better Database Migrations in Postgres
#80Earlier quoted context omitted.
You mean heap-only-tuples: https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f...
Yes, I was just about to post https://github.com/postgres/postgres/blob/master/src/backend... I misremembered it a little in my original post. (I'm not able to open your link for some reason :-\)