diff schema/gemma.sql @ 361:f5087cebc740

Enforce PostgreSQL identifier length on username A name longer than 63 bytes will be truncated on role creation, rendering user_profiles.username and the actual name of the role out of sync. The new CHECK constraint prevents such situation.
author Tom Gottfried <tom@intevation.de>
date Wed, 08 Aug 2018 16:31:23 +0200
parents b97b3172c61a
children 78588014ad0a
line wrap: on
line diff
--- a/schema/gemma.sql	Wed Aug 08 15:47:44 2018 +0200
+++ b/schema/gemma.sql	Wed Aug 08 16:31:23 2018 +0200
@@ -40,7 +40,8 @@
 CREATE SCHEMA internal
     -- Profile data are only accessible via the view users.list_users.
     CREATE TABLE user_profiles (
-        username varchar PRIMARY KEY,
+        username varchar PRIMARY KEY CHECK(octet_length(username) <= 63),
+        -- keep username length compatible with role identifier
         map_extent box2d NOT NULL,
         email_address varchar NOT NULL
     )