Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PendingMigrationError even after running rails db:migrate #210

Open
shaam48 opened this issue Nov 29, 2022 · 0 comments
Open

PendingMigrationError even after running rails db:migrate #210

shaam48 opened this issue Nov 29, 2022 · 0 comments

Comments

@shaam48
Copy link

shaam48 commented Nov 29, 2022

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

@shaam48 shaam48 changed the title PendingMigrationError when running rails db:migrate PendingMigrationError even after running rails db:migrate Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant