我正在两个不同应用程序的数据库之间创建逻辑复制。然而,在开发环境中,我的数据库保留在同一个 postgres docker 容器中。
我的应用程序使用 Rails,因此我创建了一个迁移来创建来自发布者的订阅。但当我运行它时,它永远有效。如果我创建另一个容器并将数据库分开,订阅就会膨胀。
无论如何,我可以在同一个容器中运行它吗?
我正在创建一个这样的foo对象:
@foo = Foo.new(foo_params)
@foo.bar = Bar.where(name: "baz").first_or_create
Run Code Online (Sandbox Code Playgroud)
但是我还需要做其他一些事情.所以,我想过重写Foo初始化方法来做这样的事情:
class Foo < ApplicationRecord
def initialize(*args, BarName)
@foo = super
@foo.bar = Bar.where(name: BarName).first_or_create
end
end
Run Code Online (Sandbox Code Playgroud)
并称之为:
@foo = Foo.new(foo_params, "baz")
Run Code Online (Sandbox Code Playgroud)
但是Foo是一个ApplicationRecord,似乎不建议覆盖ApplicationRecord初始化方法.
那怎么能这样呢?还有其他想法吗?这会初始化压倒一切吗?
我正在为我的一个应用程序使用 postgres:11.6-alpine 图像,我想在设置时将图像 wal_level 设置为“逻辑”,最好使用 docker-compose。
我找到的解决方案需要您覆盖图像 postgresql.conf。但是,我不想为了更改此设置而拥有完整的 postgresql.conf 文件。
有什么办法可以做到这一点吗?
我在 MacOS 上通过 Docker Desktop 运行 Docker,在容器中安装软件包时遇到很多麻烦,因为它无法验证任何 ssl 证书。
\napk update例如,当我运行时,我收到此错误:
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz\n139797308250952:error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:ssl/statem/statem_clnt.c:1914:\nERROR: https://dl-cdn.alpinelinux.org/alpine/v3.14/main: Permission denied\nRun Code Online (Sandbox Code Playgroud)\n当我尝试bundle install:
Could not verify the SSL certificate for https://rubygems.org/.\nThere is a chance you are experiencing a man-in-the-middle attack, but most likely your system doesn\'t have the CA certificates needed for verification.\nRun Code Online (Sandbox Code Playgroud)\n甚至是一个简单的卷曲curl https://google.com.br:
curl: (60) SSL certificate problem: unable to get local issuer certificate\nMore details here: https://curl.se/docs/sslcerts.html\n\ncurl failed to …Run Code Online (Sandbox Code Playgroud)