On Saturday, August 12, 2017 at 11:21:37 AM UTC-7, Sergey Kislyakov wrote:
> I have a very simple database structure in my project that looks like that:
> # /db/migrate/001_create_posts.rb
> Sequel.migration do
> change do
> create_table :posts do
> primary_key :id
> String :title, null: false
> String :description, null: false
> String :body, null: false, text: true
> TrueClass :published, null: false, default: true
> # /db/database.rb
> module DB
> Connection = Sequel.sqlite('database.rb')
You are naming the database database.rb here. You probably want to use
database.db to match the migration file name used below.
> class Post < Sequel::Model
> I've did
> bundle exec sequel -m db/migrate db/database.db
> Here is where you are creating the posts table in a database.db file.
> It worked and I can access the table using
Note that this just creates a dataset, it doesn't actually run code on the
database or make sure the posts table exists.
> However, when I'm trying to run the `database.rb` file, I get this warning:
> SEQUEL DEPRECATION WARNING: Setting a model class dataset to an invalid
> dataset is deprecated and will be removed in Sequel 5. Either use a
> valid dataset or set require_valid_table = false for the model class.
> lib/sequel/model/base.rb:1008:in `rescue in check_non_connection_error'
> `block in get_db_schema'
> lib/sequel/model/base.rb:1156:in `get_db_schema'
> db/database.rb:5:in `<main>'
> Is there something I need to change? I've spent my whole day trying to
> find why I get the warning, no luck.
This is Sequel correctly warning that you created a Post model where the
underlying table (posts) does not actually exist in the database. If it
didn't warn now (and raise an error in Sequel 5), it would definitely fail
later when you actually tried to use the model.
You received this message because you are subscribed to the Google Groups
To unsubscribe from this group and stop receiving emails from it, send an email
To post to this group, send email to firstname.lastname@example.org.
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.