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

Aidbox migrations #4

Open
pavlushkin opened this issue May 14, 2020 · 0 comments
Open

Aidbox migrations #4

pavlushkin opened this issue May 14, 2020 · 0 comments

Comments

@pavlushkin
Copy link
Member

pavlushkin commented May 14, 2020

We can use Aidbox REST Console to run SQL queries.

Reference: Postgres JSON Functions and Operators

Ex. 1: Deletion of an aidbox resource attribute

Updated resource example (the filter attribute to be deleted):

id: d6fdcc6a-4513-45df-8f06-797a4727ce7f
resourceType: MedicalRule
sourceQuery:
  id: Source
  type: batch
  entry:
    - request:
        url: $snowstorm
        method: POST
      resource:
        ecl: '<< 372586001 |Hypotensive agent (substance)|'
        filter: '...'  // <- to be deleted
        resourceType: SnowstormRequest

Migration SQL query (for all resources of this type):

update medicalrule 
set resource = jsonb_set(
   resource, 
   '{sourceQuery,entry,0,resource}', 
   (resource #> '{sourceQuery,entry,0,resource}')- 'filter'
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant