On Wed, Oct 14, 2020 at 2:50 PM François Beausoleil <
[email protected]> wrote:

> Hi all!
>
> Detailed version info at the bottom.
>
> On a new app, I'm trying sequel-rails. It seems that Sequel::Model classes
> eagerly attempt to read their table schema. This prevents deployment to
> Heroku as asset precompilation happens before migrations, and asset
> precompilation must boot the app.
>
> The order of operations seems to be similar to the following:
>
> bin/rails g model person name:text
> bin/rails db:migrate
> git add --all
> git commit --message "Person model"
> git push heroku
>     - bin/rails assets:precompile
>         - Rails eagerly loads models, because RAILS_ENV=production
>         - Person attempts to read the table schema
>         - PG correctly raises an exception, as the table does not exist
>
> I did define release in my Procfile, but migrations are run after asset
> precompilation.
>
> As a test, I changed config/environments/production.rb to set eager_load
> to false, alas, to no effect.
>
> I searched this group's archive with "sequel model eager load schema", but
> that only matched release announcements. DuckDuckGo also returns a bunch of
> results about Sequelize, EntityFramework and other tools. The search terms
> are probably too generic. I read the Sequel::Model documentation as well,
> but didn't find anything that seemed relevant.
>
> Is there a way to tell Sequel::Model instances to delay trying to read the
> schema? Failing that, would you have other workarounds?
>

You can try Sequel::Model.require_valid_table = false before loading your
model classes, at least when you are doing asset precompilation.  That
doesn't make the classes lazy load, that just ignores errors.  That may be
an acceptable work around.  A better solution would be fixing Rails so it
runs migrations before asset precompilation, or make asset precompilation
not load the models.

Thanks,
Jeremy

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/CADGZSSfD7VN4pKvTM1T54V5TecF8ziGhUeTNBVX94XTpxf%2BmFw%40mail.gmail.com.

Reply via email to