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

Migration script to convert event data & metadata from bytea to jsonb #97

Open
slashdotdash opened this issue Jan 2, 2018 · 3 comments

Comments

@slashdotdash
Copy link
Member

Support for jsonb data type has been added in #86. It would be useful to provide a data migration script to convert existing (JSON encoded) bytea event data and metadata to jsonb.

@mquickform
Copy link

Posting it her for posterity, might be useful (postgres)

ALTER TABLE events 
  ALTER COLUMN data TYPE jsonb USING convert_from(data, 'UTF8')::jsonb,
  ALTER COLUMN metadata TYPE jsonb USING convert_from(metadata, 'UTF8')::jsonb;

@Fire-Dragon-DoL
Copy link

As a side note, it should be performed for snapshots table too.

@Fire-Dragon-DoL
Copy link

In case you don't have convert_from available in your postgres installation (I don't have it in mine and I'm not sure where it's coming from):

alter table events alter column metadata type jsonb using (metadata #>> '{}')::jsonb, alter column data type jsonb using (data #>> '{}')::jsonb;
alter table snapshots alter column metadata type jsonb using (metadata #>> '{}')::jsonb, alter column data type jsonb using (data #>> '{}')::jsonb;

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

3 participants