You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/DBAL/Platform/PostgreSQLPlatform.php
+61-10Lines changed: 61 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -23,13 +23,29 @@ public function createSchemaManager(Connection $connection): PostgreSQLSchemaMan
23
23
24
24
publicfunctiongetListEnumTypesSQL(): string
25
25
{
26
-
return'SELECT pg_type.typname AS name,
27
-
pg_enum.enumlabel AS label,
28
-
pg_description.description AS comment
29
-
FROM pg_type
30
-
JOIN pg_enum ON pg_enum.enumtypid = pg_type.oid
31
-
LEFT JOIN pg_description on pg_description.objoid = pg_type.oid
32
-
ORDER BY pg_enum.enumsortorder';
26
+
return'WITH types AS (
27
+
SELECT pg_type.typname AS name,
28
+
pg_enum.enumlabel AS label,
29
+
pg_enum.enumsortorder AS label_order,
30
+
pg_description.description AS comment,
31
+
pg_class.relname AS usage_table,
32
+
pg_attribute.attname AS usage_column,
33
+
PG_GET_EXPR(pg_attrdef.adbin, pg_attrdef.adrelid) AS usage_default
34
+
FROM pg_type
35
+
JOIN pg_enum ON pg_enum.enumtypid = pg_type.oid
36
+
LEFT JOIN pg_description ON pg_description.objoid = pg_type.oid
37
+
LEFT JOIN pg_depend ON pg_depend.refobjid = pg_type.oid
38
+
LEFT JOIN pg_class ON pg_class.oid = pg_depend.objid
39
+
LEFT JOIN pg_attribute ON pg_attribute.attrelid = pg_class.oid AND pg_attribute.atttypid = pg_type.oid
40
+
LEFT JOIN pg_attrdef ON pg_attrdef.adrelid = pg_class.oid AND pg_attrdef.adnum = pg_attribute.attnum
41
+
)
42
+
SELECT types.name,
43
+
types.comment,
44
+
JSON_AGG(DISTINCT JSONB_BUILD_OBJECT(\'label\', types.label, \'order\', types.label_order)) AS labels,
45
+
JSON_AGG(DISTINCT JSONB_BUILD_OBJECT(\'table\', types.usage_table, \'column\', types.usage_column, \'default\', types.usage_default)) FILTER (WHERE types.usage_table IS NOT NULL AND types.usage_column IS NOT NULL) AS usages
46
+
FROM types
47
+
GROUP BY types.name, types.comment'
48
+
;
33
49
}
34
50
35
51
/**
@@ -59,13 +75,48 @@ public function getAlterTypeSql(EnumTypeAsset $from, EnumTypeAsset $to): array
0 commit comments