Kind: SGScript
listKind: SGScriptList
plural: sgscripts
singular: sgscript
shortNames sgscr
The SGScript custom resource represents an ordered list of versioned SQL scripts.
Example:
apiVersion: stackgres.io/v1beta1
kind: SGScript
metadata:
name: script
spec:
managedVersions: true
continueOnError: false
scripts:
- name: create-stackgres-user
scriptFrom:
secretKeyRef: # read the user from a Secret to maintain credentials in a safe place
name: stackgres-secret-sqls-scripts
key: create-stackgres-user.sql
- name: create-stackgres-database
script: |
CREATE DATABASE stackgres WITH OWNER stackgres;
- name: create-stackgres-schema
database: stackgres
scriptFrom:
configMapKeyRef: # read long script from a ConfigMap to avoid have to much data in the helm releasea and the sgcluster CR
name: stackgres-sqls-scripts
key: create-stackgres-schema.sql
See also SQL Scripts section.
Property |
Description |
|---|---|
|
Workaround for hugo bug not rendering first table row
|
|
| apiVersion string |
stackgres.io/v1 Constraints: required, immutable |
| kind string |
SGScript Constraints: required, immutable |
| metadata object |
Refer to the Kubernetes API documentation for the fields of the metadata field.Constraints: required, updatable |
| spec object |
Constraints: required, updatable |
| status object |
Constraints: optional, updatable |
Property |
Description |
|---|---|
|
Workaround for hugo bug not rendering first table row
|
|
| continueOnError boolean |
If
true, when any script entry fails, it will not prevent subsequent script entries from being executed. false by default.
Constraints: optional, updatable |
| managedVersions boolean |
If
true the versions will be managed by the operator automatically. The user will still be able to update them if needed. true by default.
Constraints: optional, updatable |
| scripts []object |
A list of SQL scripts.
Constraints: optional, updatable |
Scripts are executed in auto-commit mode with the user postgres in the specified database (or in database postgres if not specified).
Fields script and scriptFrom are mutually exclusive and only one of them is required.
Property |
Description |
|---|---|
|
Workaround for hugo bug not rendering first table row
|
|
| database string |
Database where the script is executed. Defaults to the
postgres database, if not specified.
Constraints: optional, updatable |
| id integer |
The id is immutable and must be unique across all the script entries. It is replaced by the operator and is used to identify the script for the whole life of the
SGScript object.
Constraints: optional, updatable Default: -1 |
| name string |
Name of the script. Must be unique across this SGScript.
Constraints: optional, updatable |
| retryOnError boolean |
If not set or set to
false the script entry will not be retried if it fails.
When set to This is Constraints: optional, updatable |
| script string |
Raw SQL script to execute. This field is mutually exclusive with
scriptFrom field.
Constraints: optional, updatable |
| scriptFrom object |
Reference to either a Kubernetes Secret or a ConfigMap that contains the SQL script to execute. This field is mutually exclusive with
script field.
Fields Constraints: optional, updatable |
| storeStatusInDatabase boolean |
When set to
true the script entry execution will include storing the status of the execution of this
script entry in the table managed_sql.status that will be created in the specified database. This
will avoid an operation that fails partially to be unrecoverable requiring the intervention from the user
if used in conjunction with retryOnError.
If set to This is Constraints: optional, updatable |
| user string |
User that will execute the script. Defaults to the superuser username when not set (that by default is
postgres).
Constraints: optional, updatable |
| version integer |
Version of the script. It will allow to identify if this script entry has been changed.
Constraints: optional, updatable |
| wrapInTransaction string |
Wrap the script in a transaction using the specified transaction mode:
If not set the script entry will not be wrapped in a transaction
Constraints: optional, updatable |
Reference to either a Kubernetes Secret or a ConfigMap that contains the SQL script to execute. This field is mutually exclusive with script field.
Fields secretKeyRef and configMapKeyRef are mutually exclusive, and one of them is required.
Property |
Description |
|---|---|
|
Workaround for hugo bug not rendering first table row
|
|
| configMapKeyRef object |
A ConfigMap reference that contains the SQL script to execute. This field is mutually exclusive with
secretKeyRef field.
Constraints: optional, updatable |
| secretKeyRef object |
A Kubernetes SecretKeySelector that contains the SQL script to execute. This field is mutually exclusive with
configMapKeyRef field.
Constraints: optional, updatable |
A ConfigMap reference that contains the SQL script to execute. This field is mutually exclusive with secretKeyRef field.
Property |
Description |
|---|---|
|
Workaround for hugo bug not rendering first table row
|
|
| key string |
The key name within the ConfigMap that contains the SQL script to execute.
Constraints: optional, updatable |
| name string |
The name of the ConfigMap that contains the SQL script to execute.
Constraints: optional, updatable |
A Kubernetes SecretKeySelector that contains the SQL script to execute. This field is mutually exclusive with configMapKeyRef field.
Property |
Description |
|---|---|
|
Workaround for hugo bug not rendering first table row
|
|
| key string |
The key of the secret to select from. Must be a valid secret key.
Constraints: optional, updatable |
| name string |
Name of the referent. More information.
Constraints: optional, updatable |
Property |
Description |
|---|---|
|
Workaround for hugo bug not rendering first table row
|
|
| scripts []object |
A list of script entry statuses where a script entry under
.spec.scripts is identified by the id field.
Constraints: optional, updatable |
Property |
Description |
|---|---|
|
Workaround for hugo bug not rendering first table row
|
|
| hash string |
The hash of a ConfigMap or Secret referenced with the associated script entry.
Constraints: optional, updatable |
| id integer |
The id that identifies a script entry.
Constraints: optional, updatable |