@@ -44,6 +44,29 @@ postgres-reload-modules:
44
44
# Database states
45
45
46
46
{%- for name, db in postgres.databases| dictsort() % }
47
+ {%- if ' extensions' in db % }
48
+ {%- for ext_name, extension in db.pop(' extensions' )| dictsort() % }
49
+ {%- do extension.update({' name' : ext_name, ' maintenance_db' : name}) % }
50
+
51
+ {{ format_state( name + ' -' + ext_name, ' postgres_extension' , extension) }}
52
+ - require:
53
+ - postgres_database: postgres_database- {{ name }}
54
+ {%- if ' schema' in extension % }
55
+ - postgres_schema: postgres_schema- {{ extension.schema }}
56
+ {%- endif % }
57
+
58
+ {%- endfor % }
59
+ {%- endif % }
60
+ {%- if ' schemas' in db % }
61
+ {%- for schema_name, schema in db.pop(' schemas' )| dictsort() % }
62
+ {%- do schema.update({' name' : schema_name, ' dbname' : name }) % }
63
+
64
+ {{ format_state( name + ' -' + schema_name, ' postgres_schema' , schema) }}
65
+ - require:
66
+ - postgres_database: postgres_database- {{ name }}
67
+
68
+ {%- endfor % }
69
+ {%- endif % }
47
70
48
71
{{ format_state(name, ' postgres_database' , db) }}
49
72
{%- if ' owner' in db or ' tablespace' in db % }
@@ -63,8 +86,9 @@ postgres-reload-modules:
63
86
{%- for name, schema in postgres.schemas| dictsort() % }
64
87
65
88
{{ format_state(name, ' postgres_schema' , schema) }}
66
- {%- if ' owner' in schema % }
67
89
- require:
90
+ - postgres_database- {{ schema.dbname }}
91
+ {%- if ' owner' in schema % }
68
92
- postgres_user: postgres_user- {{ schema.owner }}
69
93
{%- endif % }
70
94
0 commit comments