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

db:rollback uses second latest migration for tenants #56

Closed
betelgeuse opened this issue May 28, 2020 · 2 comments · Fixed by #57
Closed

db:rollback uses second latest migration for tenants #56

betelgeuse opened this issue May 28, 2020 · 2 comments · Fixed by #57

Comments

@betelgeuse
Copy link

Steps to reproduce

rails db:rollback

Expected behavior

Rolling back latest migration

Actual behavior

Tenants try to roll back with n - 1.

== 20200528194507 Latest: reverting =============================
== 20200528194507 Latest: reverted (0.0526s) ====================

Rolling back testtenant1 tenant
== 20200526235656  SecondLatest: reverting ======================
-- failing_statement
rails aborted!

System configuration

  • Database: (Tell us what database and its version you use.) PostgreSQL 10.0

  • Apartment version: 2.6.0

  • Apartment config (in config/initializers/apartment.rb or so):

    • tenant_names: -> { 'a', 'b', 'dev' }
    • use_schemas: true
    • default_schema: dev
    • persistent_schemas: %w[shared_extensions]
  • Rails (or ActiveRecord) version: 6.0.3

  • Ruby version: 2.7.0

@rpbaltazar
Copy link
Contributor

Thank you for reporting. I'm able to reproduce it on main development branch. I'll take a look at why is it happening and try to fix it!

@rpbaltazar
Copy link
Contributor

Ok, I can see why.
when we enhance the rollback task, we have already ran it for the default schema. but your default schema is also on the list of tenant names, so it rollsback the n-1 for dev.
it should be an easy fix.

@rpbaltazar rpbaltazar linked a pull request Jun 1, 2020 that will close this issue
rpbaltazar added a commit that referenced this issue Jun 2, 2020
Prepare Release - 2.6.1

# Enhancements

- N/a

# Bugfixes

- [Resolves influitive#607] Avoid early connection
  - #39
  - #53
  - #51
- [Resolves #52] Rake db:setup tries to seed non existent tenant - #54
- [Resolves #56] DB rollback uses second last migration - #57

# Chores

- N/a
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

Successfully merging a pull request may close this issue.

2 participants