如何格式化class TestConst {
final num x;
final num y;
const TestConst(this.x, this.y);
}
void main() {
TestConst myconst1 = TestConst(1,2);
TestConst myconst2 = TestConst(1,2);
print(identical(myconst1, myconst2));
}
命令,使其能够捕获配置文件中的所有数据库?
rake db:create:all RAILS_ENV=development
使用# config/database.yml
db1:
development:
adapter: mysql2
host: 127.0.0.1
database: db1
username: user
password: pass
test:
.
.
db2:
development:
adapter: mysql2
host: 127.0.0.1
database: db2
username: user
password: pass
test:
.
.
db3:
development:
adapter: mysql2
host: 127.0.0.1
database: db3
username: user
password: pass
test:
.
.
时,我希望创建所有数据库(db1,db2,db3),但仅创建db1。
答案 0 :(得分:0)
多重数据库支持将是Rails 6的一项新功能,尚未发布。参见https://weblog.rubyonrails.org/2019/1/18/Rails-6-0-Action-Mailbox-Action-Text-Multiple-DBs-Parallel-Testing/
database.yml
中的YAML结构看起来与您的YAML结构略有不同-请参见https://github.com/rails/rails/pull/33877#issuecomment-422150252
答案 1 :(得分:0)
对于rails6,您可以提供多个连接,并为每个连接指定数据库, 例如:-database.yml
adapter: postgresql
encoding: unicode
username: username
password: password
pool: 5
host: localhost
development:
primary:
<<: *default
database: database1
adapter: postgresql
secondary:
<<: *default
database: database2
adapter: postgresql
您可以执行rails db:create
来创建database1和database2
您可以执行rails db:create:primary
仅创建database1(因为它属于主连接)。