2

使用 ruby​​ 2.5,rails 4.2.11,

我正在为一个过去只是直接发送到生产环境的 ruby​​ 项目设置开发环境。

HotWire 包含特定于应用程序的数据,而 QualityDC 包含许多其他应用程序共享的关系信息。我将如何设置它以便我可以添加一个 QualityDC_Dev 实例以供 development.rb 环境使用?

在 database.yml 文件中(在我的 /etc 文件夹中引用 odbc.ini,我有以下内容:

development:
  adapter: sqlserver
  mode: odbc
  dsn: HotWire_Dev
  username: webserver
  password: password
  pool: 5
  timeout: 5000

qualitydc:
  adapter: sqlserver
  mode: odbc
  dsn: qualitydc
  username: webserver
  password: wordpass
  pool: 5
  timeout: 5000

production:
  adapter: sqlserver
  mode: odbc
  dsn: HotWire
  username: webserver
  password: password
  pool: 5
  timeout: 5000

odbc.ini 条目:

[BrazeWire]
Driver          = /usr/lib64/libtdsodbc.so.0
Server          = server.domain.com
Database        = HotWire
tds_version     = 8.0
Port            = 1433

[BrazeWire_Test]
Driver          = /usr/lib64/libtdsodbc.so.0
Server          = server.domain.com
Database        = HotWire_Dev
tds_version     = 8.0
Port            = 1433'

[QUALITYDC]
Driver      = FreeTDS
Server      = server.domain.com
Database    = QualityDC
tds_version     = 8.0
Port        = 1433
4

1 回答 1

1

找到另一个引用它的线程,因为 4.2 不支持分组,所以不得不做出一个 janky 解决方法:

Using ruby 2.5, rails 4.2.11,

I'm setting up a dev environment for a ruby project that used to just send straight to production.

HotWire contains application specific data while QualityDC contains much of the relational information shared by the other applications. How would I set it up so I can add a QualityDC_Dev instance to be used by the development.rb environment?

In the database.yml file (that references odbc.ini in my /etc folder, I have the following:

development:
  adapter: sqlserver
  mode: odbc
  dsn: HotWire_Dev
  username: webserver
  password: password
  pool: 5
  timeout: 5000

development_qualitydc:
  adapter: sqlserver
  mode: odbc
  dsn: qualitydc_Dev
  username: webserver
  password: wordpass
  pool: 5
  timeout: 5000

production:
  adapter: sqlserver
  mode: odbc
  dsn: HotWire
  username: webserver
  password: password
  pool: 5
  timeout: 5000

production_qualitydc:
  adapter: sqlserver
  mode: odbc
  dsn: qualitydc
  username: webserver
  password: wordpass
  pool: 5
  timeout: 5000

在模型中:

class HotWire< ActiveRecord::Base
  establish_connection "#{Rails.env}_qualitydc"
    self.table_name = 'QualityDC.dbmaster.HotWire'
  #set_primary_key :id_number
end
于 2020-12-08T19:11:41.363 回答