api - 我可以从 Heroku Postgres 备份主键吗?

标签 api postgresql heroku primary-key database-backups

我们正在构建一个 API,该 API 当前公开数据库主键以选择参数。我担心 pg_dump(和基于它的 Heroku pgbackups)显然不备份主键。 (参见 Postgres pg_dump dumps database in a different order every time)

如果我需要升级我们的数据库或将其复制到暂存区,我可以使用 Heroku 的追随者或 fork 功能并保留主键。 (参见 https://devcenter.heroku.com/articles/heroku-postgres-follower-databaseshttps://devcenter.heroku.com/articles/heroku-postgres-fork )。但是,导出数据库以用于开发会丢失顺序(请参阅 https://devcenter.heroku.com/articles/heroku-postgres-import-export )。

所以,如果我不能备份它们,Is it a bad idea to use a database table's ID as an external API identifier?

我是否应该考虑在每个参数表上创建一个 UUID 列并将其公开? (参见 http://www.codinghorror.com/blog/2007/03/primary-keys-ids-versus-guids.html)

我发现像/v1/products?category=14,16&partner=3&q=plaid 这样的 URL 对于开发人员来说更容易使用,但我担心我会因为太难迁移而将自己锁定在 Heroku 中。

提前感谢您的建议。

最佳答案

I'm concerned that pg_dump (and Heroku pgbackups which is based on it) apparently do not backup primary keys.

别担心。他们当然得到支持。这不是链接项目的意思。

该项目表示无法保证行转储的顺序。这并不意味着 (id=1, name="fred") 会丢失 (id=1) 只是因为它可能不会(在备份文件中)列为第一项。张贴者关心的唯一原因是他试图将备份文件作为文本进行比较。

关于api - 我可以从 Heroku Postgres 备份主键吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17188798/

相关文章:

java - Eclipse API : How to get IFile from an IProject using only the file name?

api - 微服务 Http 状态代码

django - squashmigrations 用法(如何找到 'migration_name' )

ssl - Heroku SSL 使用自签名证书

ssl - Heroku SSL 端点的问题

python - 如何使用python通过浏览器下载数据框

php - Botman laravel REST API 设置

java - 从java发送电子邮件

SQL:将列的数据类型从字符串更改为数字

postgresql - 有没有什么快速的方法可以在同一台服务器上的集群之间移动 PostgreSQL 数据库?