Skip to content

Fixed default dashboard entry in PostgreSQL schema - #306

Open
pfournier wants to merge 1 commit into
OpenSIPS:masterfrom
pfournier:pgsql-schema-fix
Open

pfournier wants to merge 1 commit into
OpenSIPS:masterfrom
pfournier:pgsql-schema-fix

Conversation

@pfournier

Copy link
Copy Markdown
Contributor

Backtick is not a valid quote character for table names in PostgreSQL and strings containing C-style escaped characters should be prefixed with the letter "E".

SpyKeeR added a commit to SpyKeeR/opensips-cp-pgsql that referenced this pull request Jul 29, 2026
config/db_schema.pgsql was a mechanical conversion of the MySQL dump and
carried several defects that make a fresh PostgreSQL install non-functional:

* ocp_dashboard INSERT used backticks (MySQL identifier quoting, a syntax
  error in PostgreSQL) so the default dashboard was never inserted. The two
  JSON literals also relied on MySQL backslash escaping; with
  standard_conforming_strings = on the backslashes are kept verbatim and
  json_decode() returns null -- an invalid dashboard with no SQL error at
  all. Backticks removed, both literals prefixed with E. (see upstream OpenSIPS#306)

* ocp_tools_config declared three independent UNIQUE constraints on module,
  param and box_id instead of the composite UNIQUE (module, param, box_id)
  of the MySQL schema, allowing only one row per module in the whole table.
  (see upstream OpenSIPS#310)

* ocp_boxes_config lost the name column and its UNIQUE constraint, which is
  the root cause of the "Undefined array key name" warnings raised by
  config/boxes.load.php and the boxes_config templates.

* ocp_extra_stats had no unique key, leaving no conflict target for the
  upsert in smonitor/statistics.php. Added UNIQUE (name, tool, box_id).

* ocp_monitoring_stats lost PRIMARY KEY (name, time, box_id) with no index
  in replacement, and ocp_monitored_stats had its primary key reduced to
  name alone, preventing a statistic from being monitored on more than one
  box. Both restored.

* The INSERTs forcing assoc_id=1 and id=1 never consumed their sequence.
  MySQL readjusts AUTO_INCREMENT on an explicit insert, PostgreSQL does not,
  so the first system or panel added through the UI failed on a duplicate
  key. Added setval() after both.

* Dropped the trailing CREATE TABLE config block: it collides with OpenSIPS'
  own scripts/postgres/config-create.sql, which is authoritative.

* Removed the three SET CLIENT_ENCODING TO 'latin1' statements, leftovers
  from a MySQL dump; the target encoding is UTF8.

Also adds POSTGRESQL.md documenting each fix and its upstream status.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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 this pull request may close these issues.

1 participant