diff --git a/Importing-Mongo-dump-to-local-(macos).md b/Importing-Mongo-dump-to-local-(macos).md index ab300c3..2fbd8d1 100644 --- a/Importing-Mongo-dump-to-local-(macos).md +++ b/Importing-Mongo-dump-to-local-(macos).md @@ -1,11 +1,9 @@ -*This is just an obsidian note I made for myself a day after going through this process. It may not, and likely isn't, 100% accurate or the best way to do something.* - 7/29/2025 CalculusChild did an export from Mongo Atlas of our database, something that I think is actually referred to as a "snapshot". It was a big *gzip* file, or `abc.tar.gz` file extension, and contained `.wt` or "wireTiger" files. This data dump is *not* used by mongorestore. So that documentation won't work for importing the DB into a local mongo db. -Here is what I did, warts and all. Also note, I did find the Mongo Chat AI to be marginally useful. +Here is what I did, warts and all. !! Be sure you have the same Mongo version as the live Homebrewery site is using at the time of the data export. At this time, that was Mongo Community 6.0. @@ -86,30 +84,43 @@ And hoping it says "started" and not "error". ## 5. Use Mongo Compass to connect At this point I switched to Mongo Compass GUI to connect the server and check that I could connect, and look for the db name I needed to connect to. As downloaded, the database name that I had to point towards was `heroku_cjpfxl1z`, not `homebrewery` as I had earlier (and is the suggested name in the Homebrewery github repo readme when creating the mongo server initially). -## 6. Update db.js in repo -I'm not sure this is or should be necessary, but it made it work for me: I had to update the `server/db.js` file in the Homebrewery repo so that the app tried to connect to the correct db: +## 6. Update the mongodb_uri location +The downloaded db data may use a different database name than what you previously had. For example, when first setting up Homebrewery locally on your machine the readme.md suggests using "homebrewery" as the name of the database. The app uses this as the default name it expects. But in my case, the db downloaded from Atlas had the name `heroku_cjpfxl1z`. So I need to update that in the app. -```js -// ... +Up to this point all of my app configuration was done in `/config/default.json`. Now, I duplicated that file and renamed it `/config/local.json` and added a line for the `mongodb_uri` property: +```json +// config/local.json +{ -const getMongoDBURL = (config)=>{ +"host" : "homebrewery.local.naturalcrit.com:8000", -return config.get('mongodb_uri') || +"naturalcrit_url" : "local.naturalcrit.com:8010", -config.get('mongolab_uri') || +"secret" : "secret", -'mongodb://127.0.0.1/heroku_cjpfxl1z'; // update this line +"web_port" : 8000, -}; +"enable_v3" : true, -// ... +"enable_themes" : true, + +"local_environments" : ["docker", "local"], + +"publicUrl" : "https://homebrewery.naturalcrit.com", + +"hb_images" : null, + +"hb_fonts" : null, + +"mongodb_uri" : "mongodb://127.0.0.1/heroku_cjpfxl1z" + +} ``` +Now I can set that db path separate from the rest of the code base-- `local.json` is included in the `.gitignore` file so changes here don't get uploaded to Github. ## 7. Restart app At this point I could start up my homebrewery app and it would connect. ------ -I assume that I don't necessarily need to update `db.js` but instead could use a config parameter somewhere. Alternatively, I couldn't find where i could change the name of an existing DB to match 'homebrewery' that i had originally-- the mongo docs suggest it isn't possible, but that you can copy all the collections of a db to a new db, renaming it in the process. - -I also had a problem where the Vault wouldn't search because of an issue with a missing `text` index for `title` query, which seems odd-- it seems like that should be a part of the export of the live site mongo db. Especially since there are plenty of Indexes that came with it. But I just added a text index for title and it worked again. +I had a problem where the Vault wouldn't search because of an issue with a missing `text` index for `title` query, which seems odd-- it seems like that should be a part of the export of the live site mongo db. Especially since there are plenty of Indexes that came with it. But I just added a text index for title and it worked again.