PendingMigrationError even after running rails db:migrate
shaam48 opened this issue · 0 comments
Steps to reproduce
Create any migration (create table, add field to a table etc.) and then run rails db:migrate
Expected behavior
We're expecting for the migration to go through without the ActiveRecord::PendingMigrationError presenting itself when viewing the application on the rails server.
Actual behavior
When migrating with rails db:migrate
the migration goes through and propagates to the schema, however, when checking on the rails server with the tenant and without the tenant I am getting the ActiveRecord::PendingMigrationError with Migrations are pending. To resolve this issue, run: bin/rails db:migrate RAILS_ENV=development
page. Upon looking at the schema.rb
, it seems like the migration has gone through and the field has been added. Also, when checking the model in the rails console the migration (a field change, creation of table etc.) is also present there. At the moment, the work around is that I drop the db and then recreate it with the migration, obviously this is something that will only be possible while I am in development but when deploying to production, this won't be possible as dropping the db will cause tables and data to be lost.
System configuration
-
Database: (Tell us what database and its version you use.)
Postgres 14.2 -
Apartment version:
2.11.0 -
Apartment config (in
config/initializers/apartment.rb
or so):
require 'apartment/elevators/subdomain'
Apartment.configure do |config|
config.excluded_models = %w{ ExcludedModel }
config.tenant_names = lambda { Table.pluck :subdomain }
end
Rails.application.config.middleware.insert_before Warden::Manager, Apartment::Elevators::Subdomain
-
Rails (or ActiveRecord) version:
5.2.7 -
Ruby version:
2.5.0