netboxlabs / netbox-branching

Official NetBox Labs plugin that implements git-like branching functionality for NetBox
http://netboxlabs.com
Other
67 stars 1 forks source link

Error: The connection 'schema_branch_BRANCH' doesn't exist #167

Open mhdask opened 2 weeks ago

mhdask commented 2 weeks ago

Plugin Version

0.5.1

NetBox Version

4.1.6

Python Version

3.10.12

Steps to Reproduce

My setup looks like this: I am running postgresql and redis in docker, using docker-compose:

version: '3.4'
services:
  postgres:
    image: postgres:15-alpine
    volumes:
      - netbox-postgres-data:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=netbox
      - POSTGRES_PASSWORD=
      - POSTGRES_USER=netbox
      - POSTGRES_HOST_AUTH_METHOD=trust
    ports:
      - 5432:5432
  redis:
    ports:
      - 6379:6379
    image: redis:7-alpine
volumes:
  netbox-postgres-data:
    driver: local
  netbox-redis-data:
    driver: local
  1. Run command GRANT CREATE ON DATABASE $database TO $user;
  2. Install plugin (I installed using local_requirements.py)
  3. Put netbox_branching as the last plugin in the file
  4. Create local_settings:
    
    from netbox_branching.utilities import DynamicSchemaDict
    from .configuration import DATABASE

Wrap DATABASES with DynamicSchemaDict for dynamic schema support

DATABASES = DynamicSchemaDict({ 'default': DATABASE, })

Employ our custom database router

DATABASE_ROUTERS = [ 'netbox_branching.database.BranchAwareRouter', ]


5. Start netbox (i activate virtual environment, and use command `python3 netbox/manage.py runserver`
6. Create branch
7. Try to switch to branch - Error occurs

### Expected Behavior

I expected that I would be able to switch to the branch

### Observed Behavior

Error `The connection 'schema_branch_BRANCH' doesn't exist`
jeremystretch commented 2 weeks ago

The connection 'schema_branch_BRANCH' doesn't exist

This error message suggests that the DATABASES setting was not loaded from local_settings.py. This may be a complication of your Docker implementation. Check that local_settings.py exists in the same path as settings.py.

mhdask commented 2 weeks ago

@jeremystretch

The connection 'schema_branch_BRANCH' doesn't exist

This error message suggests that the DATABASES setting was not loaded from local_settings.py. This may be a complication of your Docker implementation. Check that local_settings.py exists in the same path as settings.py.

local_settings.py is located in the same path as settings.py:

/home/user/development/netbox/netbox/netbox/local_settings.py
/home/user/development/netbox/netbox/netbox/settings.py