This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-07-22
Channels
I got my prod db in a bad state… it tried deleting all the records to reset it. it seems like its holding some values in a place (index?) I dont understand. Im signing up with a user that doesnt exist but get a validation error that says the email violates the unique constraint. I had the email in the db before but now im signing up again. whats the best way to reset back to a fresh db?
if you delete the storage/xtdb
directory in prod, that'll delete the index (and the transaction log + doc store, unless you set up Postgres). then do a bb restart
I deleted all the users in the db and then tried to sign up with the same email… just deleted storage/xtdb
and ran bb restart
but still got this error:
clojure.lang.ExceptionInfo: Transaction violated a constraint {:tx ([:xtdb.api/match #uuid "059f8246-da94-46ce-b0db-5e879e208adf" nil] [:xtdb.api/put {:user/joined-at #inst "2023-07-22T17:55:50.887-00:00", :user/email "", :xt/id #uuid "059f8246-da94-46ce-b0db-5e879e208adf"}] [:xtdb.api/fn :biff/ensure-unique {:user/email ""}])}

to really make sure everything's cleared out, you can:
1. ssh into the server as root and run systemctl stop app
2. delete the storage/xtdb
directory
3. drop the Postgres db. I think you can do this from the digitalocean website
4. then run bb restart
sorry for all the n00b questions lol when yall run data migrations (I want to seed the db) currently im just connecting to the repl and executing transactions by hand… is there and “official” way you do this? I know people use migratus for schema migrations but with xtdb, that seems less of a problem 🙂
no worries 🙂 the way you're doing it is how I'd do it to. agreed there's less of a need for migration tools. even when I do want to do some sort of migration (e.g. add a new required attribute to all existing docs in the database) I just code it up as a plain fn and call it from the repl.
do you mean during or after the migration? the more entities are involved, the longer the migration will take to run, same as all queries/transactions
during. That’s true, just wondering if you hit a certain number of entities in a transaction where using the repl causes problems. I think i’m getting ahead of myself 😄
🙂 I do usually batch the transaction, so instead of one big transaction, I'll do multiple transactions with, say, 500 documents at a time