Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guide for implementing YAML import #2441

Open
mattr- opened this issue Jul 26, 2020 · 1 comment
Open

Guide for implementing YAML import #2441

mattr- opened this issue Jul 26, 2020 · 1 comment
Labels
Enhancement ⚡️ New features, big or small.

Comments

@mattr-
Copy link
Member

mattr- commented Jul 26, 2020

I just moved hosting providers for my Tracks instance, and exported YAML, and reimported it. Since YAML import isn't implemented, I had to do it by hand from a console. If this functionality is desired, here is some notes about how I did it:


Rails' autoloading was fun here, perhaps because i did this in a development environment console rather than a production console? Not sure. Either way, I had to require a bunch of model classes before the YAML would even parse correctly when loaded from disk.


Import order:

  • contexts
  • projects
  • tags
  • recurring todos
  • todos
  • taggings

For referential integrity purposes, the ordering is pretty important, since there's all sorts of ids in the yaml export. The order above allowed me to import everything keep everything linked properly.


When load in the YAML, you get actual objects. Calling save on them does nothing though, because ActiveRecord thinks they're not needing to be saved. I had to use create with the attributes with something like:

yaml["contexts"].each { |item| Context.create(item.attributes) }

One of the reasons this was so successful is because i have a single user instances of tracks that isn't very busy. We'd have to make serious considerations for things like multiple users, different ids for model data, etc.

Feel free to close this after reading. I just wanted to share the information. 😃

@ZeiP
Copy link
Member

ZeiP commented Jul 26, 2020

I think this is a valid issue, it'd be good to have better import capabilities for our own exports. Thanks for the good start!

@ZeiP ZeiP added the Enhancement ⚡️ New features, big or small. label Jul 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ⚡️ New features, big or small.
Projects
None yet
Development

No branches or pull requests

2 participants