Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

@truffle/db Option to save .db directory to project directory #4503

Closed
wants to merge 9 commits into from

Conversation

tenthirtyone
Copy link
Contributor

@tenthirtyone tenthirtyone commented Dec 8, 2021

Summary

Adds the saveLocally property to the db section of the truffle-config.js

db: {
      enabled: true,
      saveLocally: true,      
    },

When enabled, the db adapters will return the working directory as the location to save the .db folder.

To Test

  1. Enable the db flag above in your truffle-config.js.
  2. I tested using db-kit, it's enough to just start the application.

ER: .db directory exists in ~/.config/truffle-nodejs/ (@truffle/config getTruffleDataDirectory())

  1. Bomb out of db-kit (ctrl-c)
  2. Enable the saveLocally config flag above with the already enabled db flag.
  3. Start db-kit

ER: .db directory exists in your truffle project directory (@truffle/config detect().working_directory)

Closes #4495

@gnidan
Copy link
Contributor

gnidan commented Dec 8, 2021

It looks like this PR modifies the project-level config, where we ideally want to save users the trouble of configuring this on a per-project basis... instead I think we want this to be a user-level config option. Happy to explain more in our next call.

Copy link
Contributor

@gnidan gnidan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few minor things. thanks for taking this on!

@@ -33,7 +33,8 @@ Add the following to your `truffle-config.js` file in order to enable Truffle DB

```
db: {
enabled: true
enabled: true,
saveLocally: true // Optional - save the .db directory to the project directory. Default: false.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be in this example anymore, since we've moved this option from truffle-config over to the user-level config

packages/db/src/meta/pouch/adapters/fs.ts Outdated Show resolved Hide resolved
packages/db/src/meta/pouch/adapters/fs.ts Outdated Show resolved Hide resolved
packages/db/src/meta/pouch/adapters/sqlite.ts Outdated Show resolved Hide resolved
@cds-amal
Copy link
Member

saveLocally is ambiguous. Would you consider db.saveToProjectRoot?

@tenthirtyone
Copy link
Contributor Author

@cds-amal You got it, thanks for taking a look.

Copy link
Contributor

@gnidan gnidan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just one remaining comment about the README. Thanks @tenthirtyone!

.gitignore Show resolved Hide resolved
Note: Enabling Truffle DB does not affect artifacts, but will produce a new `.db`
directory when you compile or migrate your project.

Add the following to your user truffle config (`~/.config/truffle-nodejs/config.json`) to enable saving the `.db` directory to your project directory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there's some infrastructure for doing this automatically via truffle config set <...>. I forget the exact syntax; @eggplantzzz or @cds-amal do you remember offhand?

In any event, we probably want to recommend that approach rather than forcing users to find this file and edit it manually - since the path differs based on OS (Mac will use ~/Library/Application\ Support/truffle-nodejs, for instance)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh fantastic.

I wasn't aware of the convenience command. I can probably drill down - packages/core/lib/commands/config.js (but wouldn't mind the exact syntax).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we need to do a separate PR to get this TODO addressed, and then rebase this once that's merged?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can jump over to tackle it since it's all connected.

@tenthirtyone
Copy link
Contributor Author

Closing and making it part of #4680

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Users should be able to configure the default location for @truffle/db persistence
3 participants