class CreateItems < ActiveRecord::Migration[8.1] def change create_table :items do |t| t.references :user, null: false, foreign_key: true, index: true t.string :name, null: false t.string :item_type, null: false t.references :platform, foreign_key: true, index: true t.string :condition t.decimal :price_paid, precision: 10, scale: 2 t.string :location t.date :date_added, null: false t.text :notes t.integer :igdb_id t.timestamps end add_index :items, :igdb_id # Enable Row Level Security execute <<-SQL ALTER TABLE items ENABLE ROW LEVEL SECURITY; CREATE POLICY items_isolation_policy ON items USING (user_id = current_setting('app.current_user_id', true)::bigint); SQL end end