New default DB file location, and how to keep using the current DB file as is via customizing

Very recent (about 5 hours ago as I write this) commit 32bf910 introduces a new default location for your org-roam.db file.

Move the default location of org-roam.db to the user’s Emacs
directory. This is a more sensible default: those who sync their
Org files would not have the database synced over as well.

Good change if you sync your notes via Cloud sync services (you would not need to explicitly exclude the .db file from sync).

This change might surprise you if you have used Org-roam since before this change, as Org-roam would try to build another database file from scratch. Depending on the size of your notes repository, it might take noticeable time.

There is no harm using a new file in the new default location.

But for whatever reason, if you prefer to keep using the DB file you have already built, you can tell Org-roam to do so by using this customizing variable.

It exists before the change, so you can set it up before you update your Org-roam package.

(setq org-roam-db-location "c:/Users/nobiot/org-roam/org-roam.db")

or via customizing like this:

1 Like

Or, if you don’t wish to rebuild the database from scratch, it is possible (I think) to simply move the db file over without any issues :smile:

1 Like

I have a feeling you might also need to move/copy the org-id file (?) I don’t use IDs, so can’t be sure :sweat_smile:

BTW, in my workflow I’m using multiple different database files. This works a treat:

(defvar org-roam-library `(,(concat "/home/" (getenv "USER") "/arxana/org-roam/")
                           ,(concat "/home/" (getenv "USER") "/org-roam/")
                           ,(concat "/home/" (getenv "USER") "/eightfold-path/")
                           ,(concat "/home/" (getenv "USER") "/PeeragogyORG/")))

(defun org-roam-checkout ()
  (let ((ctx org-roam-directory))
    (if (eq (length org-roam-library) 1)
        ;; Still go ahead and set the variable in this case!
        (progn (setq org-roam-directory (car org-roam-library))
               (message "You only have one choice for org-roam-directory defined."))
      (let ((lib (completing-read "Choose a volume: " org-roam-library)))
        (when lib
          (setq org-roam-directory lib))))
    ;; assuming the user changes context, let’s also prompt them
    ;; to choose a new file in that context
    (when (not (eq ctx org-roam-directory))

It looks like in light of the change, the org-roam-checkout function should be adjusted to set the org-roam-db-location as well as the org-roam-directory. Will sort it out shortly…

1 Like

Nope, Org-roam caches the IDs and uses it to navigate, rather than rely on Org’s file cache mechanism

1 Like

That looks like a very sophisticated setup!
I switch between my notes directory and test directory manually evaluating (setq org-roam-directory ...) etc. :sweat_smile:
Maybe time for adding a toggle function at least…