Migrating from multiple databases to a single database?

I’m relatively new to Django (and web systems architecture more broadly) and mistakenly thought that building my project with separate databases for user data and core application data was a good idea. I originally created two applications, core and users, with separate router classes:

settings.py

DATABASES = {
        "default": {
        },
        USERS_DATABASE: {
            "ENGINE": "django.db.backends.postgresql",
            "NAME": "postgres",
            "USER": ...,
            "PASSWORD": ...,
            "HOST": "127.0.0.1",
            "PORT": "5000",
        },
        CORE_DATABASE: {
            "ENGINE": "django.db.backends.postgresql",
            "NAME": "postgres",
            "USER": ...,
            "PASSWORD": ...,
            "HOST": "127.0.0.1",
            "PORT": "5000",
        },
    }

routers.py

class AuthRouter:
    route_app_labels = {
        "auth",
        "contenttypes",
        "sessions",
        "admin",
    }
   ...

class CoreRouter:
    route_app_labels = {
        "core",
    }
   ...

Knowing now that it’s not necessary for our project to use separate core and users databases (and that doing so will give us more problems in the future), I’d like to migrate the users database into the core database and assign the core database to be the default. There are only two users at the moment, so I’m fine with losing the users data and recreating the superuser if need be.

However, migrating the users database doesn’t seem as straightforward as editing settings.py and creating migrations. Editing the databases settings.py to both point to the core database and running migrate for auth, admin, contenttypes, or sessions doesn’t do anything. Is there a way to force Django to recreate the tables for these apps (that were originally routed to the users database) in the core database to undo my original decision to use separate databases?

Edit: In fact, it’s not a problem for me to lose all of the data in the core database and start with a clean slate. But since I’m new to Django, I’m not sure what I need to change in my project for it to be safe for me to do so. I suspect to start clean, I’d simply need to do migrate {app} zero for all apps, drop all tables in the core database, and re-run migrate.

Easiest:

  • Remove the extra database defintions
  • Remove the routers
  • Drop and recreate the database
  • Run migrate