-- Create table with tsvector column
CREATE TABLE articles (
id SERIAL PRIMARY KEY,
title VARCHAR(200),
content TEXT,
author VARCHAR(100),
class AddSearchVectorToArticles < ActiveRecord::Migration[7.1]
def up
execute <<~SQL
ALTER TABLE articles
ADD COLUMN search_vector tsvector
GENERATED ALWAYS AS (
class Article < ApplicationRecord
include PgSearch::Model
pg_search_scope :full_text_search,
against: { title: 'A', body: 'B' },
using: {