Problem
Most table names in the DB scripts are written without quotes (e.g. CREATE TABLE ROLE_PERMISSION). In PostgreSQL, unquoted identifiers are case-folded to lowercase, so these tables are effectively stored as lowercase (e.g. role_permission).
However, a handful of table names clash with SQL reserved keywords — ROLE and GROUP — and are therefore wrapped in double quotes to avoid parse errors:
| Script |
Table |
Declaration |
configdb/postgres.sql, configdb/sqlite.sql |
ROLE |
CREATE TABLE "ROLE" |
userdb/postgres.sql, userdb/sqlite.sql |
GROUP |
CREATE TABLE "GROUP" |
Because they are quoted, PostgreSQL preserves their case exactly as written (ROLE, GROUP), while all other tables end up lowercase. This creates an inconsistent schema where mixing queries against quoted and unquoted names requires knowing which tables are keywords and which are not.
Root cause
Quoting is necessary for reserved-word table names and cannot be removed. The inconsistency arises because the non-keyword tables are left unquoted.
Proposed fix
Quote all table names across every DB script (configdb, runtimedb, userdb) so that casing is uniformly preserved in uppercase. For example:
-- Before
CREATE TABLE ROLE_PERMISSION (
...
FOREIGN KEY (ROLE_ID) REFERENCES "ROLE" (ID) ON DELETE CASCADE
);
-- After
CREATE TABLE "ROLE_PERMISSION" (
...
FOREIGN KEY (ROLE_ID) REFERENCES "ROLE" (ID) ON DELETE CASCADE
);
This change affects all CREATE TABLE, CREATE INDEX, FOREIGN KEY REFERENCES, and any ad-hoc INSERT/SELECT statements inside the scripts.
Any Go source files that embed raw SQL table names (e.g. in query strings) will also need to be updated to use the quoted uppercase form.
Problem
Most table names in the DB scripts are written without quotes (e.g.
CREATE TABLE ROLE_PERMISSION). In PostgreSQL, unquoted identifiers are case-folded to lowercase, so these tables are effectively stored as lowercase (e.g.role_permission).However, a handful of table names clash with SQL reserved keywords —
ROLEandGROUP— and are therefore wrapped in double quotes to avoid parse errors:configdb/postgres.sql,configdb/sqlite.sqlROLECREATE TABLE "ROLE"userdb/postgres.sql,userdb/sqlite.sqlGROUPCREATE TABLE "GROUP"Because they are quoted, PostgreSQL preserves their case exactly as written (
ROLE,GROUP), while all other tables end up lowercase. This creates an inconsistent schema where mixing queries against quoted and unquoted names requires knowing which tables are keywords and which are not.Root cause
Quoting is necessary for reserved-word table names and cannot be removed. The inconsistency arises because the non-keyword tables are left unquoted.
Proposed fix
Quote all table names across every DB script (
configdb,runtimedb,userdb) so that casing is uniformly preserved in uppercase. For example:This change affects all
CREATE TABLE,CREATE INDEX,FOREIGN KEY REFERENCES, and any ad-hocINSERT/SELECTstatements inside the scripts.Any Go source files that embed raw SQL table names (e.g. in query strings) will also need to be updated to use the quoted uppercase form.