postgresql_16
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesepostgresql_16
postgresql_16
PostgreSQL 16 es la base de datos relacional principal del pipeline de verificación de identidad. Se utiliza para persistir sesiones de verificación, resultados de auditoría, configuración del pipeline KYC y los scores emitidos por cada módulo. Aprovecha las mejoras de rendimiento y las nuevas funcionalidades de la versión 16 como paralelismo mejorado y logical replication optimizada.
PostgreSQL 16是身份验证流程的主关系型数据库,用于持久化验证会话、审计结果、KYC流程配置以及各模块输出的评分。它利用了16版本的性能提升和新功能,比如改进的并行处理能力和优化的逻辑复制。
When to use
适用场景
Usa esta skill cuando necesites instalar, configurar o desplegar PostgreSQL 16 como datastore principal del sistema KYC. Pertenece al database_agent y se aplica durante la fase de setup inicial de infraestructura o al migrar desde versiones anteriores.
当你需要安装、配置或部署PostgreSQL 16作为KYC系统的主数据存储时使用此skill。它属于database_agent,适用于基础设施初始搭建阶段或从旧版本迁移的场景。
Instructions
使用说明
- Definir la versión exacta de PostgreSQL 16 en el Dockerfile del servicio de base de datos:
dockerfile
FROM postgres:16-alpine
ENV POSTGRES_DB=verifid_kyc
ENV POSTGRES_USER=verifid_admin
COPY ./init-scripts/ /docker-entrypoint-initdb.d/- Configurar parámetros de rendimiento en adaptados al pipeline KYC:
postgresql.conf
conf
shared_buffers = '1GB'
effective_cache_size = '3GB'
work_mem = '64MB'
maintenance_work_mem = '256MB'
max_connections = 200
wal_level = 'replica'
max_wal_senders = 5- Crear el schema inicial con las tablas principales del sistema de verificación:
sql
CREATE SCHEMA kyc;
CREATE TABLE kyc.verification_sessions (
session_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
status VARCHAR(20) NOT NULL DEFAULT 'pending',
confidence_score NUMERIC(5,4),
reasons JSONB,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
completed_at TIMESTAMPTZ,
ip_address INET,
device_fingerprint TEXT
);
CREATE TABLE kyc.audit_logs (
log_id BIGSERIAL PRIMARY KEY,
session_id UUID REFERENCES kyc.verification_sessions(session_id),
module_name VARCHAR(50) NOT NULL,
module_score NUMERIC(5,4),
details JSONB,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);- Habilitar extensiones necesarias para el pipeline:
sql
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE EXTENSION IF NOT EXISTS "pg_stat_statements";
CREATE EXTENSION IF NOT EXISTS "pgcrypto";- Configurar roles y permisos según el principio de mínimo privilegio:
sql
CREATE ROLE verifid_app LOGIN PASSWORD 'secure_password';
GRANT USAGE ON SCHEMA kyc TO verifid_app;
GRANT SELECT, INSERT, UPDATE ON ALL TABLES IN SCHEMA kyc TO verifid_app;
GRANT USAGE ON ALL SEQUENCES IN SCHEMA kyc TO verifid_app;- Configurar para restringir accesos solo desde la red interna del cluster:
pg_hba.conf
conf
undefined- 在数据库服务的Dockerfile中定义PostgreSQL 16的精确版本:
dockerfile
FROM postgres:16-alpine
ENV POSTGRES_DB=verifid_kyc
ENV POSTGRES_USER=verifid_admin
COPY ./init-scripts/ /docker-entrypoint-initdb.d/- 在中配置适配KYC流程的性能参数:
postgresql.conf
conf
shared_buffers = '1GB'
effective_cache_size = '3GB'
work_mem = '64MB'
maintenance_work_mem = '256MB'
max_connections = 200
wal_level = 'replica'
max_wal_senders = 5- 创建初始schema以及验证系统的核心表:
sql
CREATE SCHEMA kyc;
CREATE TABLE kyc.verification_sessions (
session_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
status VARCHAR(20) NOT NULL DEFAULT 'pending',
confidence_score NUMERIC(5,4),
reasons JSONB,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
completed_at TIMESTAMPTZ,
ip_address INET,
device_fingerprint TEXT
);
CREATE TABLE kyc.audit_logs (
log_id BIGSERIAL PRIMARY KEY,
session_id UUID REFERENCES kyc.verification_sessions(session_id),
module_name VARCHAR(50) NOT NULL,
module_score NUMERIC(5,4),
details JSONB,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);- 启用流程所需的扩展:
sql
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE EXTENSION IF NOT EXISTS "pg_stat_statements";
CREATE EXTENSION IF NOT EXISTS "pgcrypto";- 按照最小权限原则配置角色和权限:
sql
CREATE ROLE verifid_app LOGIN PASSWORD 'secure_password';
GRANT USAGE ON SCHEMA kyc TO verifid_app;
GRANT SELECT, INSERT, UPDATE ON ALL TABLES IN SCHEMA kyc TO verifid_app;
GRANT USAGE ON ALL SEQUENCES IN SCHEMA kyc TO verifid_app;- 配置仅允许集群内部网络访问:
pg_hba.conf
conf
undefinedTYPE DATABASE USER ADDRESS METHOD
TYPE DATABASE USER ADDRESS METHOD
host verifid_kyc verifid_app 10.0.0.0/8 scram-sha-256
host verifid_kyc verifid_admin 10.0.0.0/8 scram-sha-256
host all all 0.0.0.0/0 reject
7. Añadir el servicio al `docker-compose.yml` del proyecto:
```yaml
services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_DB: verifid_kyc
POSTGRES_USER: verifid_admin
POSTGRES_PASSWORD_FILE: /run/secrets/db_password
volumes:
- pgdata:/var/lib/postgresql/data
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U verifid_admin -d verifid_kyc"]
interval: 10s
timeout: 5s
retries: 5host verifid_kyc verifid_app 10.0.0.0/8 scram-sha-256
host verifid_kyc verifid_admin 10.0.0.0/8 scram-sha-256
host all all 0.0.0.0/0 reject
7. 将服务添加到项目的`docker-compose.yml`中:
```yaml
services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_DB: verifid_kyc
POSTGRES_USER: verifid_admin
POSTGRES_PASSWORD_FILE: /run/secrets/db_password
volumes:
- pgdata:/var/lib/postgresql/data
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U verifid_admin -d verifid_kyc"]
interval: 10s
timeout: 5s
retries: 5Notes
注意事项
- PostgreSQL 16 introduce mejoras significativas en paralelismo de queries y logical replication que benefician las consultas analíticas sobre sesiones de verificación.
- Las imágenes biométricas NO deben almacenarse en PostgreSQL; se usa MinIO para almacenamiento temporal de blobs con políticas de lifecycle de 15 minutos.
- Siempre usar en lugar de
TIMESTAMPTZpara garantizar consistencia temporal en despliegues multi-región del pipeline KYC.TIMESTAMP
- PostgreSQL 16在查询并行性和逻辑复制方面引入了显著改进,有利于对验证会话执行分析查询。
- 生物特征图像不得存储在PostgreSQL中;这类blob临时存储使用MinIO,生命周期策略设为15分钟。
- 始终使用而非
TIMESTAMPTZ,以确保KYC流程多区域部署的时间一致性。TIMESTAMP