Brewskey / spark-server

An API compatible open source server for interacting with devices speaking the spark-protocol
https://www.particle.io/
GNU Affero General Public License v3.0
54 stars 27 forks source link

Migrate script #209

Closed lilyannh closed 7 years ago

lilyannh commented 7 years ago

I'm having trouble migrating my data files over to mongo. I've pulled the latest from the dev branch onto a fresh server, installed mongodb, copied over my old data folder, and edited the DB_CONFIG URL to 'mongodb://localhost' in the settings file.

When I run npm run migrate-to-mongo I get the following:

> spark-server@0.1.1 migrate-to-mongo /root/spark-server
> babel-node ./src/scripts/migrateFilesToDatabase mongo

Setup database connection...
Start migration to mongo
All files migrated to the database successfully!

...but i don't see any changes to the .db files in the /data/db folder.

I have been running a version of the server where the users, webhooks, and deviceAttributes were being stored in database files (these files did not have file extensions - I noticed this version generates new database files with .db extension). The device keys were still individual files in the /deviceKeys folder.

AntonPuko commented 7 years ago

Currently, we have 4 variants of how to store data 1) files, it stores in data/[entityFolder] 2) tingoDb, it stores in data/db/[entityName with no extension] 3) neDb, it stores in data/db/[entityName].db 4) mongoDb, it stores where you pointed during monodb setup.

We have migration scripts from files to mongo or tingo only. We use neDb as primary db in the server right now. For switching the server to mongo you need to modify main.js a little bit, see the example: https://github.com/Brewskey/spark-server/blob/dev/examples/azure-mongodb.js

jlkalberer commented 7 years ago

@AntonPuko - can you update the migration script to neDb? Tingo should be completely removed now.

lilyannh commented 7 years ago

Thanks for the quick update. I was able to migrate my deviceKeys over to neDb.

I have a problem where all my deviceAttributes, users, and webhooks were all set up using Tingo. Is there a way to migrate those over? I can just re-add the webhooks in the particle CLI, so that's not a big deal, but the deviceAttributes and users are a different story...

AntonPuko commented 7 years ago

there isn't tingo - to other script, but I think you should be able to write it by yourself looking on migrateFilesToDatabase.js