Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions engine/config/1.0/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -446,27 +446,30 @@
"type": "object",
"description": "Configures the persistent storage system.",
"properties": {
"embedded": {
"in_memory": {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted all the changes to 1.0/schema.json since we are using 2.0 to break backwards compatibility. I think we want to keep 1.0 where it is - lmk if I'm missing something.

"type": "object",
"description": "Use an embedded PostgreSQL database for local development. Data is persisted to the specified data path.",
"description": "Use an in-memory database (data is not persisted between restarts). If storage is not configured, this is the default.",
"additionalProperties": false
}
},
"required": ["in_memory"],
"additionalProperties": false
},
{
"type": "object",
"description": "Configures the persistent storage system.",
"properties": {
"sqlite": {
"type": "object",
"description": "Use a SQLite database for persistent storage.",
"properties": {
"data_path": {
"type": "string",
"description": "The path where PostgreSQL data will be stored. Defaults to ~/.arcade/postgres-data if not specified."
},
"port": {
"description": "The port for the embedded PostgreSQL server. Defaults to 5432.",
"oneOf": [
{ "type": "integer", "default": 5432 },
{ "$ref": "#/$defs/envVarPattern" },
{ "$ref": "#/$defs/filePattern" }
]
}
"connection_string": { "type": "string" }
},
"required": ["connection_string"],
"additionalProperties": false
}
},
"required": ["embedded"],
"required": ["sqlite"],
"additionalProperties": false
},
{
Expand All @@ -475,7 +478,7 @@
"properties": {
"postgres": {
"type": "object",
"description": "Use an external PostgreSQL database for persistent storage.",
"description": "Use a PostgreSQL database for persistent storage.",
"properties": {
"user": { "type": "string" },
"password": { "type": "string" },
Expand Down Expand Up @@ -515,7 +518,7 @@
},
{
"type": "null",
"description": "No storage configuration is set. Uses embedded PostgreSQL with default settings."
"description": "No storage configuration is set. Uses an in-memory database (data is not persisted between restarts)."
}
]
},
Expand Down
13 changes: 7 additions & 6 deletions engine/config/2.0/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,14 @@ security:

storage:
postgres:
user: ${env:POSTGRES_USER}
password: ${env:POSTGRES_PASSWORD}
host: ${env:POSTGRES_HOST}
port: ${env:POSTGRES_PORT}
db: ${env:POSTGRES_DB}
sslmode: require
data_path: ${env:POSTGRES_DATA_PATH}
# Or, connect to an external Postgres instance:
# user: ${env:POSTGRES_USER}
# password: ${env:POSTGRES_PASSWORD}
# host: ${env:POSTGRES_HOST}
# port: ${env:POSTGRES_PORT}
# db: ${env:POSTGRES_DB}
# sslmode: require


telemetry:
Expand Down
105 changes: 57 additions & 48 deletions engine/config/2.0/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -449,63 +449,72 @@
"postgres": {
"type": "object",
"description": "PostgreSQL configuration. Use 'data_path' for embedded mode (local development) or 'host' for external mode (production).",
"properties": {
"data_path": {
"type": "string",
"description": "Enables embedded PostgreSQL mode. Data is stored at this path. Defaults to ~/.arcade/postgres-data if not specified. Mutually exclusive with 'host'."
},
"host": {
"type": "string",
"description": "The hostname of the external PostgreSQL server. When set, connects to an external database instead of using embedded mode."
},
"port": {
"description": "The port for the PostgreSQL server. Defaults to 5432.",
"oneOf": [
{ "type": "integer", "default": 5432 },
{ "$ref": "#/$defs/envVarPattern" },
{ "$ref": "#/$defs/filePattern" }
]
},
"user": {
"type": "string",
"description": "The username for the PostgreSQL connection. Required for external mode."
},
"password": {
"type": "string",
"description": "The password for the PostgreSQL connection. Required for external mode."
},
"db": {
"type": "string",
"description": "The database name. Required for external mode."
"oneOf": [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oneOf encodes the mutual-exclusivity that we describe in data_path.description at the schema level. So the schema will validate with either data_path or host/port/user/etc but not with both.

{
"type": "object",
"properties": {
"data_path": {
"type": "string",
"description": "Enables embedded PostgreSQL mode. Data is stored at this path. Defaults to ~/.arcade/postgres-data if empty or not specified. Mutually exclusive with 'host'."
}
},
"required": ["data_path"],
"additionalProperties": false
},
"sslmode": {
"description": "The SSL mode for the PostgreSQL connection. Required for external mode.",
"oneOf": [
{
{
"type": "object",
"properties": {
"host": {
"type": "string",
"enum": [
"disable",
"allow",
"prefer",
"require",
"verify-ca",
"verify-full"
"description": "The hostname of the external PostgreSQL server. When set, connects to an external database instead of using embedded mode."
},
"port": {
"description": "The port for the PostgreSQL server. Defaults to 5432.",
"oneOf": [
{ "type": "integer", "default": 5432 },
{ "$ref": "#/$defs/envVarPattern" },
{ "$ref": "#/$defs/filePattern" }
]
},
{ "$ref": "#/$defs/envVarPattern" },
{ "$ref": "#/$defs/filePattern" }
]
"user": {
"type": "string",
"description": "The username for the PostgreSQL connection. Required for external mode."
},
"password": {
"type": "string",
"description": "The password for the PostgreSQL connection. Required for external mode."
},
"db": {
"type": "string",
"description": "The database name. Required for external mode."
},
"sslmode": {
"description": "The SSL mode for the PostgreSQL connection. Required for external mode.",
"oneOf": [
{
"type": "string",
"enum": [
"disable",
"allow",
"prefer",
"require",
"verify-ca",
"verify-full"
]
},
{ "$ref": "#/$defs/envVarPattern" },
{ "$ref": "#/$defs/filePattern" }
]
}
},
"required": ["host", "port", "user", "password", "db", "sslmode"],
"additionalProperties": false
}
},
"additionalProperties": false
]
}
},
"required": ["postgres"],
"additionalProperties": false
},
{
"type": "null",
"description": "No storage configuration is set. Uses embedded PostgreSQL with default settings."
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this because it was kinda hard to understand. Technically we allowed storage: null which meant embedded, but I think it's much clearer to just declare what you have now:

storage:
  postgres:
    data_path: "..."

}
]
},
Expand Down