module Scrivito module Migrations class CmsBackend def read if obj = find_migration_store_obj obj.data_from_cms.value_of('versions') else '' end end def save(value) CmsRestApi.put(endpoint("objs/#{migration_store_obj.id}"), obj: {versions: ['string', value]}) Workspace.current.reload end private def create CmsRestApi.post(endpoint('objs'), obj: {_path: path, _obj_class: 'MigrationStore', versions: ['string', '']}) Workspace.current.reload end def migration_store_obj create unless find_migration_store_obj find_migration_store_obj end def find_migration_store_obj Obj.find_by_path(path) end def path '/_internal/migration-store' end def endpoint(path) "workspaces/#{Workspace.current.id}/#{path}" end end end end