Login
You're viewing the ruby.social public feed.
  • Nov 20, 2026, 4:19 AM

    I will admit things feel a little sluggish right now, despite _much_ better hardware, but PostgreSQL is live on :netbsd: and everything else is modernized too.

    Happy patch day! (Every day is patch day).

    💬 2🔄 1⭐ 1

Replies

  • Nov 21, 2026, 9:47 PM

    So, some follow up -- during the restore from backup 9 foreign key constraints failed to apply.

    This is due to work that I undertook in March 2023 after I lost some data and had to sketchily restore it into a running instance: tiny.tilde.website/@insom/1100

    To do that, I relaxed FK constraints and, to the surprise of no-one, some invalid data is there.

    Three years later I am fixing this up! I've learned about NOT VALID CONSTRAINTS since then, from my work at Slice.

    💬 1🔄 1⭐ 1
  • Nov 21, 2026, 9:49 PM

    You can add a constraint in two parts with PostgreSQL: one for new data being added (not valid) and then later you can do `alter table ... validate constraint` to ensure that historical data is validated.

    I would have loved this in MySQL for making fields UNIQUE, something that was extremely toil-filled when I worked at Shopify.

    Anyway, I've added those 9 as NOT VALID so that we don't add _new_ invalid data, to give me a chance to clean up.

    💬 1🔄 1⭐ 1
  • Nov 21, 2026, 9:51 PM

    I wrote a simple query to find the `media_attachments` which are referencing accounts that no longer exist on our server. This took a long time, so I went to Home Depot to buy stuff I need for an IRL project.

    I got a text message to my phone about the chassis being too warm 😅 -- when I came back an hour later it hadn't finished.

    Then I rewrote the `IN` to be a `LEFT JOIN` and it ran in 9 seconds. Still got it.

    Some tables are bigger so I'll be carrying on this evening; just thought I'd share.

    💬 1🔄 1⭐ 0
  • Nov 22, 2026, 4:00 AM

    And we're done. High five to 2023's @insom -- working across the years to fix the data I fucked up.

    ```
    postgres=> select count(*) from pg_constraint where not convalidated;
    count
    -------
    0
    (1 row)
    ```

    💬 0🔄 0⭐ 0
  • 💬 0🔄 3⭐ 0