Add jsonb on sqlite connection adapter table definition

Posting this here after I created an issue ticket: Add `jsonb` on sqlite connection adapter table definition · Issue #50841 · rails/rails · GitHub

With the addition of a binary json on disk format in sqlite, we sort of have a jsonb now. The column type is still json, however the format in which it is stored is jsonb. Making all json fields technically jsonb. M

I believe it would be a welcome addition to have an aliased column helper called jsonb which creates a json column in sqlite.

Reasoning

Most of the time, we start off with sqlite and move to postgres. Which requires changing all our json columns to jsonb. Adding this alias allows us to use the same migrations across sqlite and postgres successfully.

I’m happy to take a stab at a PR if this is a welcome change.

References:

https://sqlite.org/forum/forumpost/fa6f64e3dc1a5d97

As I am reading the discussion following the link you provided, it seems that JSONB is only an internal representation of sqlite and will not be exposed to the user. Or am I missing something here ?

No you’re not.

However, even if it’s not exposed as a type, in principle it means the same thing.

This proposal is to help for migrating from sqlite to postgres.

Say I intend to use postgres later, but want to test on sqlite, I can’t use the jsonb field. My proposal is to make it easier for users in this case.