Error parsing schema for model

12 views
Skip to first unread message

Sebastjan Hribar

unread,
Jul 22, 2024, 10:20:02 AM7/22/24
to Roda
Hi,

I'm trying to setup a many to many association according to docs and I get the error below for the following setup. Just for variables context, I'm building a event manager for our fire brigade, hence the danger and event.

>>>
#Migration
# frozen_string_literal: true
Sequel.migration do
  change do
    create_table(:events_dangers) do
      primary_key :id
      column :created_at, DateTime, null: false
      column :updated_at, DateTime, null: false

      foreign_key :event_id, :events
      foreign_key :danger_id, :dangers
    end
  end
end

#Event model
# frozen_string_literal: true
class Event < Sequel::Model
    many_to_many :dangers, join_table: :events_dangers, class: :EventDanger
  end

#Danger model
# frozen_string_literal: true
class Danger < Sequel::Model
    many_to_many :events, join_table: :events_dangers, class: :EventDanger
  end

#EventDanger model
# frozen_string_literal: true
class EventDanger < Sequel::Model
end

#Error when running the spec:
ruby -Ispec spec/model/event_danger_spec.rb

/home/seba-ubt/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/sequel-5.81.0/lib/sequel/plugins/require_valid_schema.rb:58:in `get_db_schema_array': Not able to parse schema for model: EventDanger, table: "event_dangers" (Sequel::Error)
<<<

I don't know why it's not parsed according to the specified join table. I've also tried without specifying the class and the error was the same.

Jeremy Evans

unread,
Jul 22, 2024, 10:22:19 AM7/22/24
to ruby...@googlegroups.com
This is a question regarding Sequel, not Roda.  Please ask on the Sequel discussion forum: https://github.com/jeremyevans/sequel/discussions

Thanks,
Jeremy
Reply all
Reply to author
Forward
0 new messages