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

Convert JSON fields from text to jsonb #1596

Open
bchrobot opened this issue May 5, 2023 · 2 comments
Open

Convert JSON fields from text to jsonb #1596

bchrobot opened this issue May 5, 2023 · 2 comments
Labels
mindless: chore 🧹 Mindless chore platform: node 🔅 Related to Node backend

Comments

@bchrobot
Copy link
Member

bchrobot commented May 5, 2023

Spoke has a number of text-type Postgres columns that store JSON values. Rather than sprinkling try { JSON.parse(json_field_name) } catch {} throughout the codebase, we should just formalize in the schema that these are JSON fields.

We should use jsonb rather than json for performance reasons. We do not care about the exact format or ordering of the input JSON text so there is no reason to use json over jsonb.

Fields:

  • campaign_contact.custom_fields
  • all_tag.confirmation_steps (may be better to migrate to its own 1:many table)
  • filtered_contact.custom_fields
  • invite.payload (already json but needs to be standardized to jsonb)
  • job_request.payload (needs confirmation that we're only using this for JSON content)
  • organization.features
@bchrobot bchrobot added mindless: chore 🧹 Mindless chore platform: node 🔅 Related to Node backend labels May 5, 2023
@lediur
Copy link
Contributor

lediur commented May 10, 2023

Could you provide a list of columns we should change, or some set of heuristics to determine whether a column needs changing? I think even a short list of examples would be a good starting place.

@bchrobot
Copy link
Member Author

Could you provide a list of columns we should change, or some set of heuristics to determine whether a column needs changing? I think even a short list of examples would be a good starting place.

I went through the schema and added a list of fields to the description. Generally it's any text column with a default of '{}'::text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mindless: chore 🧹 Mindless chore platform: node 🔅 Related to Node backend
Projects
None yet
Development

No branches or pull requests

2 participants