Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
4 posts Page 1 of 1
Hey, if you ever needed a tool to data migration, I'm developing one and will post here.
It's best usage is transferring data selectively from one database to another database which both are hosted in the same server whether local or online.
Example: massive delete cloned pages, massive create identical cloned pages or transfer data from filled editable fields - it all goes here.

I am coding a website for a client that is a bit different from the previous one, but with the same portfolio items. Would be a nightmare to copy-paste several hundreds of cloned pages and data in editables. So here tool helps.

Post your stories, samples or requests.
Ok, here is the first version, which already helps me. It can be considered as alpha.

List of funcitons:
  • Create cloned pages
  • Delete cloned pages
  • Update text field (text, textarea, nicedit)
  • Update relation field
  • Read text field

All functions rely on several variables:
source database (any database in the system that has `couch_*` tables.
target database - current couch installation, which you are running this template on.
source template - clonable template in source database.
target template - clonable template in current installation database.
source field - regular editable field, that you defined in source template
target field - regular editable from target template.

I did some effort to dynamically fetch databases, templates and fields to avoid manual typing.
I did not always use a 'paginated' approach with pauses, so some operations might complete at once. If number of cloned pages is not big (several hundreds - small, several thousands - average, 10k-100k - big), then things complete quickly in mere seconds of faster.
3. Update text field (textarea, nicedit and text fields are tested OK, the others not coded yet)
4. Update relation field (relation OK, reverse_relation not coded yet)
update-relation-field.png
update-relation-field.png (22.94 KiB) Viewed 3552 times

Consequtively choose variables and click Next or Start (once everything is chosen).
Both 3rd and 4th functions work very similar, so I post here only one screenshot.

Most data-reading operations are coded with 'cms:query' tag with direct SQL requests, inherited from those CouchCMS uses. Every data-writing operation is coded with 'cms:db_persist' tag, so data is written by CouchCMS itself, doing it natively, as if you inputted data manually in backend and saved it.
I think it is the only way at the moment to do this and results are therefore very reliable.
Added 'richtext' support.
Added new function 'Read text field' - outputs content of some text field from all pages of a chosen template in chosen db.
4 posts Page 1 of 1