PostgreSQL Storage
For common Agent integration, extraction modes, and tool configuration, see Usage and Configuration.
Use case: Production, advanced JSONB features
Set POSTGRES_DSN through environment or secret management. A production DSN
should validate the server certificate and use a host name covered by it:
Configuration options:
WithPostgresClientDSN(dsn): Recommended connection form; has the highest priorityWithHost/WithPort/WithUser/WithPassword/WithDatabase: Alternative field-based connection parametersWithSSLMode(mode): SSL mode (default "disable")WithPostgresInstance(name): Use pre-registered PostgreSQL instanceWithSoftDelete(enabled): Enable soft delete (default false)WithTableName(name): Custom table name (default "memories")WithSchema(schema): Specify database schema (default is public)WithMemoryLimit(limit): Memory limit per userWithCustomTool(toolName, creator): Register custom toolWithToolEnabled(toolName, enabled): Enable/disable toolWithExtraOptions(...options): Extra options passed to PostgreSQL clientWithSkipDBInit(skip): Skip table initialization (for users without DDL permissions)
Note: A DSN takes priority over the field-based connection parameters. Both
direct forms take priority over WithPostgresInstance. The default SSL mode is
disable; use it only for trusted local development, not production.
Registered instance example:
Default table schema (auto-created in public.memories):
WithSchema and WithTableName replace the schema and table identifiers in
this DDL and its index statements.
Resource cleanup: Call Close() method to release database connection: