Custom Field Logic Migration Doesn't Support EnterpriseDB (Commercial PostgreSQL) #2135

Closed
opened 2025-12-29 17:22:35 +01:00 by adam · 4 comments
Owner

Originally created by @tyler-8 on GitHub (Nov 20, 2018).

Environment

  • Python version: 3.6.7
  • NetBox version: 2.4.7

Steps to Reproduce

Using EnterpriseDB 10.5 (commercial PostgreSQL)...

./manage.py migrate

Expected Behavior

Migrations applied successfully

Observed Behavior

Exception is raised due to this line:
pg_version = re.match(r'^PostgreSQL (\d+\.\d+(\.\d+)?)', row[0]).group(1)

This is due to the output of SELECT VERSION(); starting with "EnterpriseDB" instead of "PostgreSQL". Rest of the output matches.

Proposed Fix:

pg_version = re.match(r'^(PostgreSQL|EnterpriseDB) (\d+\.\d+(\.\d+)?)', row[0]).group(2)

Originally created by @tyler-8 on GitHub (Nov 20, 2018). <!-- NOTE: This form is only for reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, DO NOT open an issue. Instead, post to our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report. --> ### Environment * Python version: 3.6.7 <!-- Example: 3.5.4 --> * NetBox version: 2.4.7 <!-- Example: 2.3.6 --> <!-- Describe in detail the steps that someone else can take to reproduce this bug using the current stable release of NetBox (or the current beta release where applicable). --> ### Steps to Reproduce Using EnterpriseDB 10.5 (commercial PostgreSQL)... `./manage.py migrate` <!-- What did you expect to happen? --> ### Expected Behavior Migrations applied successfully <!-- What happened instead? --> ### Observed Behavior Exception is raised due to [this line](https://github.com/digitalocean/netbox/blob/master/netbox/extras/migrations/0001_initial_squashed_0010_customfield_filter_logic.py#L26): `pg_version = re.match(r'^PostgreSQL (\d+\.\d+(\.\d+)?)', row[0]).group(1)` This is due to the output of `SELECT VERSION();` starting with "EnterpriseDB" instead of "PostgreSQL". Rest of the output matches. ### Proposed Fix: `pg_version = re.match(r'^(PostgreSQL|EnterpriseDB) (\d+\.\d+(\.\d+)?)', row[0]).group(2)`
adam added the status: acceptedtype: feature labels 2025-12-29 17:22:35 +01:00
adam closed this issue 2025-12-29 17:22:35 +01:00
Author
Owner

@jeremystretch commented on GitHub (Nov 20, 2018):

NetBox officially supports only the PostgreSQL database. While I realize that what you're requesting is a trivial change, please understand that I don't want to imply that we guarantee support for other databases, even if they are PostgreSQL-compatible. All database functions and migrations must be thoroughly tested, and we don't have the ability to test against commercial databases.

As a workaround, you can add a return line at the top of verify_postgresql_version() to effectively bypass the validation. The migration is only called once: Once it's applied, you can revert the modification to maintain parity with the official code base if you like. However, please keep in mind that we cannot assist with any issues you encounter relating to the use of an unsupported database.

@jeremystretch commented on GitHub (Nov 20, 2018): NetBox officially supports only the PostgreSQL database. While I realize that what you're requesting is a trivial change, please understand that I don't want to imply that we guarantee support for other databases, even if they are PostgreSQL-compatible. All database functions and migrations must be thoroughly tested, and we don't have the ability to test against commercial databases. As a workaround, you can add a `return` line at the top of `verify_postgresql_version()` to effectively bypass the validation. The migration is only called once: Once it's applied, you can revert the modification to maintain parity with the official code base if you like. However, please keep in mind that we cannot assist with any issues you encounter relating to the use of an unsupported database.
Author
Owner

@tyler-8 commented on GitHub (Nov 20, 2018):

I look at it more like RHEL & CentOS, Docker EE & Docker CE, Python & Active Python. For database operations, EnterpriseDB is PostgreSQL. The differences are above the actual database layer, so for the purposes of migrations and database functions, anything Django or DRF would touch, there would be no difference.

In any case, at least this issue documents the required changes should any future users stumble upon problems with EnterpriseDB and Netbox.

@tyler-8 commented on GitHub (Nov 20, 2018): I look at it more like RHEL & CentOS, Docker EE & Docker CE, Python & Active Python. For database operations, EnterpriseDB is PostgreSQL. The differences are above the actual database layer, so for the purposes of migrations and database functions, anything Django or DRF would touch, there would be no difference. In any case, at least this issue documents the required changes should any future users stumble upon problems with EnterpriseDB and Netbox.
Author
Owner

@tyler-8 commented on GitHub (Nov 20, 2018):

@jeremystretch What if this was changed to match Django's PostgreSQL version checking method?

https://github.com/django/django/blob/master/django/db/backends/postgresql/features.py#L62
https://github.com/django/django/blob/master/django/db/backends/postgresql/base.py#L281

Which itself actually uses psycopg2's method for checking the database version. This gets netbox out of the business of using a raw query and doing the version processing itself.

from django.db import connection
connection.pg_version
100512
@tyler-8 commented on GitHub (Nov 20, 2018): @jeremystretch What if this was changed to match Django's PostgreSQL version checking method? https://github.com/django/django/blob/master/django/db/backends/postgresql/features.py#L62 https://github.com/django/django/blob/master/django/db/backends/postgresql/base.py#L281 Which itself actually uses [psycopg2's method](http://initd.org/psycopg/docs/connection.html#connection.server_version) for checking the database version. This gets netbox out of the business of using a raw query and doing the version processing itself. ``` from django.db import connection connection.pg_version 100512 ```
Author
Owner

@jeremystretch commented on GitHub (Nov 20, 2018):

@tyler-8 I'm fine with that. Will re-open.

@jeremystretch commented on GitHub (Nov 20, 2018): @tyler-8 I'm fine with that. Will re-open.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2135