Skip to content

Commit

Permalink
test: prevent PSQL-only model from migrating to SQLite database
Browse files Browse the repository at this point in the history
  • Loading branch information
joaodaher committed May 7, 2024
1 parent 6610556 commit e0766b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test_app/database_routers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class FeatureRouter:
def allow_migrate(self, db, app_label, model_name=None, **hints):
if model_name in {"reservation"}: # PSQL-only
return db == "default"
return True
1 change: 1 addition & 0 deletions test_app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"NAME": str(BASE_DIR / "db.sqlite3"),
},
}
DATABASE_ROUTERS = ["test_app.database_routers.FeatureRouter"]

# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
Expand Down

0 comments on commit e0766b6

Please sign in to comment.