comments (9)

  • cursor.execute("SET file_copy_method = 'clone'") cursor.execute( f'CREATE DATABASE "{target}" TEMPLATE "{source}" STRATEGY FILE_COPY' )

    Works like a charm. Claude can set it all up for you in 20m, including branch tags and management/gc scripts. It is very familiar with this pattern and uses it well. Clones are fast and cheap, and you can basically forget about it all once it’s set up.

    caidan

  • Postgres 18 has file_copy_method = clone for this, is that used underneath or did you implement your own own?

    t0mas88

  • Super interesting, I had my own dumb script that clones the DB whenever I needed to work in a feature that requires some sort of DB mutation, some times with a lot of them going, so this does sound useful.

    Having said that lately with the speed of AI assisted development I do this less and less...

    AlexMC

  • Is this like neon DB? I tried using neon db for branching with agents, but its not that great. Ended up using different sqlite files per branch, and finally throwing away the ones not needed and consolidating all migrations eventually

    pranavs98

  • So nice to have a way to get cheap db clones, I just set up this at work recently to do the same thing https://postgres.ai/docs/database-lab

    pjm331

  • Any plans for ClickHouse? We run Postgres plus ClickHouse, and Postgres is the easy part to clone for a test env. The ClickHouse side is where it hurts, since the parts are large and immutable.

    thdaiminh

  • Is it possible to merge changes from a clone/branch back to the "official copy"?

    rzzzt

  • Are there any plans to add a rebase feature?

    adererror

  • This is interesting. Does it hook into Postgres and MySQL’s MVCC?

    n_u