SGScript holds a series of versioned SQL scripts.
The SGScript represents a ordered list of SQL scripts.
Kind: SGScript
listKind: SGScriptList
plural: sgscripts
singular: sgscript
Spec
Property | Required | Updatable | Type | Default | Description |
---|---|---|---|---|---|
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. |
||
continueOnError | ✓ | boolean |
If
true , when any script entry fail will not prevent subsequent script entries from being executed. false by default. |
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
Property | Required | Updatable | Type | Default | Description |
---|---|---|---|---|---|
name | ✓ | string |
Name of the script. Must be unique across this SGScript.
|
||
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. |
|||
version | ✓ | integer |
Version of the script. It will allow to identify if this script entry has been changed.
|
||
database | ✓ | string | postgres |
Database where the script is executed. Defaults to the
postgres database, if not specified. |
|
user | ✓ | string | postgres |
User that will execute the script. Defaults to the
postgres user. |
|
script | ✓ | string |
Raw SQL script to execute. This field is mutually exclusive with
scriptFrom field. |
||
scriptFrom | ✓ | object |
Property | Required | Updatable | Type | Default | Description |
---|---|---|---|---|---|
configMapKeyRef | ✓ | object |
A ConfigMap reference that contains the SQL script to execute. This field is mutually exclusive with
secretKeyRef field. |
||
secretKeyRef | ✓ | object |
A Kubernetes SecretKeySelector that contains the SQL script to execute. This field is mutually exclusive with
configMapKeyRef field. |
Property | Required | Updatable | Type | Default | Description |
---|---|---|---|---|---|
name | ✓ | ✓ | string |
The name of the ConfigMap that contains the SQL script to execute.
|
|
key | ✓ | ✓ | string |
The key name within the ConfigMap that contains the SQL script to execute.
|
Property | Required | Updatable | Type | Default | Description |
---|---|---|---|---|---|
name | ✓ | ✓ | string |
Name of the referent. More information.
|
|
key | ✓ | ✓ | string |
The key of the secret to select from. Must be a valid secret key.
|