*-- Solved --* Jeremy, thanks a lot for your quick response. You not only showed me how to do it, but also pointed me my a future bug (forgetting to cast).
Just as a curiosity, all the methods you suggested worked, but I had to enclose *score* with single quotes in the first one and also in 2nd and 3rd methods, instead of using symbol. Otherwise it complains that the column does not exist. Anyway, now I can see the index being used with "Explain Analyse...", and also sorting it properly (considering numeric). Thank you one more time! I love this lib! Cheers Em segunda-feira, 19 de fevereiro de 2018 14:38:45 UTC+1, João Alexandre escreveu: > > Hi folks, I couldn't find this neither in documentation or former posts. > I'm sorry if it has been mentioned already. > > I'm trying to achieve this using Postgres and Sequel: > > create index my_index_name on my_table ((meta_data->>'meta_data_key')) > > This creates a btree index on a Jsonb column called *meta_data* looking > for internal json keys with the name *meta_data_key. *So, on Sequel > migration I'm trying things like: > > Sequel.migration do > change do > alter_table :my_table do > add_column :meta_data, "Jsonb" > add_index "((meta_data->>score))".to_sym > end > end > end > > > The problem is on the `add_index "((meta_data->>score))".to_sym` line. I > keep getting a *PG::UndefinedColumn: ERROR: column "(meta_data->>score)" > does not exist.* > > I've also tried several variations like: > `add_index "meta_data->>score" > `add_index :meta_data->>score > `add_index "(meta_data->>score)" > > Does anyone know to properly do this? > > Thanks in advance! > > -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
