With a new database, running bundle exec rails db:structure:load
or rails db:create
or rails db:migrate
or bin/rails db:setup
throws
rails aborted!
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "clients"
does not exist
LINE 8: WHERE a.attrelid = '"clients"'::regclass
...etc ^
I'd be happy just knowing how to debug this. At some point, some code is calling the Client model, but it's invisible. What could be requiring the clients table to exist pre-boot?
Edits:
No migrations erased, no. The app boots fine locally where there's a database: this first occurs in CI where it's booting from scratch.
Here's the stacktrace https://gist.github.com/EmmaB/01a9322ab66f258a5ebd6883a441251f showing another missing table after I commented out the following code in a Flipper initializer:
Client::Identifiers::IDENTIFER_ID_MAPPING.each do |client_identifier, client_id|
Flipper.register(client_identifier) do |actor|
actor&.client_id == client_id
end
end
But that initialiser code shouldn't run in boot when you're loading the structure, right? And indeed doesn't run in Rails 4.2.10 (upgrading from that to 5.2).
Wrapping model calls in initializers with
Rails.configuration.after_initialize do
# Model calls
end
gets the app to boot. Initializers must be called earlier in the boot process than in Rails 4. Edit: And indeed, here's the thread https://github.com/rails/rails/issues/32870
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.