@@ -162,6 +162,59 @@ type DatabaseSpec struct {
162162 // +kubebuilder:default:=retain
163163 // +optional
164164 ReclaimPolicy DatabaseReclaimPolicy `json:"databaseReclaimPolicy,omitempty"`
165+
166+ // The list of schemas to be managed in the database
167+ // +optional
168+ Schemas []SchemaSpec `json:"schemas,omitempty"`
169+
170+ // The list of extensions to be managed in the database
171+ // +optional
172+ Extensions []ExtensionSpec `json:"extensions,omitempty"`
173+ }
174+
175+ // DatabaseObjectSpec contains the fields which are common to every
176+ // database object
177+ type DatabaseObjectSpec struct {
178+ // Name of the extension/schema
179+ Name string `json:"name"`
180+
181+ // Specifies whether an extension/schema should be present or absent in
182+ // the database. If set to `present`, the extension/schema will be
183+ // created if it does not exist. If set to `absent`, the
184+ // extension/schema will be removed if it exists.
185+ // +kubebuilder:default:="present"
186+ // +kubebuilder:validation:Enum=present;absent
187+ // +optional
188+ Ensure EnsureOption `json:"ensure"`
189+ }
190+
191+ // SchemaSpec configures a schema in a database
192+ type SchemaSpec struct {
193+ // Common fields
194+ DatabaseObjectSpec `json:",inline"`
195+
196+ // The role name of the user who owns the schema inside PostgreSQL.
197+ // It maps to the `AUTHORIZATION` parameter of `CREATE SCHEMA` and the
198+ // `OWNER TO` command of `ALTER SCHEMA`.
199+ Owner string `json:"owner,omitempty"`
200+ }
201+
202+ // ExtensionSpec configures an extension in a database
203+ type ExtensionSpec struct {
204+ // Common fields
205+ DatabaseObjectSpec `json:",inline"`
206+
207+ // The version of the extension to install. If empty, the operator will
208+ // install the default version (whatever is specified in the
209+ // extension's control file)
210+ Version string `json:"version,omitempty"`
211+
212+ // The name of the schema in which to install the extension's objects,
213+ // in case the extension allows its contents to be relocated. If not
214+ // specified (default), and the extension's control file does not
215+ // specify a schema either, the current default object creation schema
216+ // is used.
217+ Schema string `json:"schema,omitempty"`
165218}
166219
167220// DatabaseStatus defines the observed state of Database
@@ -178,6 +231,28 @@ type DatabaseStatus struct {
178231 // Message is the reconciliation output message
179232 // +optional
180233 Message string `json:"message,omitempty"`
234+
235+ // Schemas is the status of the managed schemas
236+ // +optional
237+ Schemas []DatabaseObjectStatus `json:"schemas,omitempty"`
238+
239+ // Extensions is the status of the managed extensions
240+ // +optional
241+ Extensions []DatabaseObjectStatus `json:"extensions,omitempty"`
242+ }
243+
244+ // DatabaseObjectStatus is the status of the managed database objects
245+ type DatabaseObjectStatus struct {
246+ // The name of the object
247+ Name string `json:"name"`
248+
249+ // True of the object has been installed successfully in
250+ // the database
251+ Applied bool `json:"applied"`
252+
253+ // Message is the object reconciliation message
254+ // +optional
255+ Message string `json:"message,omitempty"`
181256}
182257
183258// +genclient
0 commit comments