accounts/docs/integrations/databases.md
2026-01-26 22:21:11 +08:00

30 lines
637 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 数据库对接
## PostgreSQL
- 主业务存储使用 PostgreSQL`internal/store/postgres.go`
- Schema 位于 `sql/schema.sql`
- 迁移工具:`migratectl`
## 同步策略
仓库提供两类同步方式(见 `sql/readme.md`
1) pgsync单向异步
- 适合单主写入 + 异步同步
- 不需要超级用户权限
2) pglogical双主最终一致
- 适合多区域双写
- 需要安装 pglogical 扩展
## 常用命令
```bash
# 初始化 schema
go run ./cmd/migratectl/main.go migrate --dsn "$DB_URL"
# 校验 schema
go run ./cmd/migratectl/main.go verify --dsn "$DB_URL" --schema sql/schema.sql
```