' rails c -e production'使用错误的架构

时间:2014-05-12 12:23:24

标签: ruby-on-rails oracle ruby-on-rails-4

使用Rails 4.1.1activerecord-oracle_enhanced-adapter 1.5.4时遇到问题。

我不是为什么,但是当我使用rails c -e production时,会使用错误的架构。前一段时间,它有效。

制作服务器使用正确的架构,但我不敢重新启动它: - )

我没有在table_name课程中设置Project或其他内容。

使用rails c -e production

进行测试
Project.count
=> (7.5ms)  SELECT column_name AS name, data_type AS sql_type, data_default, nullable, virtual_column, hidden_column, data_type_owner AS sql_type_owner, DECODE(data_type, 'NUMBER', data_precision, 'FLOAT', data_precision, 'VARCHAR2', DECODE(char_used, 'C', char_length, data_length), 'RAW', DECODE(char_used, 'C', char_length, data_length), 'CHAR', DECODE(char_used, 'C', char_length, data_length), NULL) AS limit, DECODE(data_type, 'NUMBER', data_scale, NULL) AS scale FROM all_tab_cols WHERE owner = 'USER_DEV' AND table_name = 'PROJECTS' AND hidden_column = 'NO' ORDER BY column_id
=> Sequence (0.8ms)  select us.sequence_name from all_sequences us where us.sequence_owner = 'USER_DEV' and us.sequence_name = 'PROJECTS_SEQ'
=> Primary Key (8.2ms)  SELECT cc.column_name FROM all_constraints c, all_cons_columns cc WHERE c.owner = 'USER_DEV' AND c.table_name = 'PROJECTS' AND c.constraint_type = 'P' AND cc.owner = c.owner AND cc.constraint_name = c.constraint_name
=> (0.8ms)  SELECT COUNT(*) FROM "PROJECTS"
=> 2


Rails.env
=> "production"

Rails.configuration.database_configuration[Rails.env]
=> {"adapter"=>"oracle_enhanced", "database"=>"(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=XXX)(PORT=1521)))(CONNECT_DATA=(SID=XXX)))", "username"=>"USER", "password"=>"XXX"}

使用rails c

进行测试
Project.count
=> (9.4ms)  SELECT column_name AS name, data_type AS sql_type, data_default, nullable, virtual_column, hidden_column, data_type_owner AS sql_type_owner, DECODE(data_type, 'NUMBER', data_precision, 'FLOAT', data_precision, 'VARCHAR2', DECODE(char_used, 'C', char_length, data_length), 'RAW', DECODE(char_used, 'C', char_length, data_length), 'CHAR', DECODE(char_used, 'C', char_length, data_length), NULL) AS limit, DECODE(data_type, 'NUMBER', data_scale, NULL) AS scale FROM all_tab_cols WHERE owner = 'USER_DEV' AND table_name = 'PROJECTS' AND hidden_column = 'NO' ORDER BY column_id
=> Sequence (0.8ms)  select us.sequence_name from all_sequences us where us.sequence_owner = 'USER_DEV' and us.sequence_name = 'PROJECTS_SEQ'
=> Primary Key (8.1ms)  SELECT cc.column_name FROM all_constraints c, all_cons_columns cc WHERE c.owner = 'USER_DEV' AND c.table_name = 'PROJECTS' AND c.constraint_type = 'P' AND cc.owner = c.owner AND cc.constraint_name = c.constraint_name
=> (0.8ms)  SELECT COUNT(*) FROM "PROJECTS"
=> 2

Rails.env
=> "development"

Rails.configuration.database_configuration[Rails.env]
=> {"adapter"=>"oracle_enhanced", "database"=>"(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=XXX)(PORT=1521)))(CONNECT_DATA=(SID=XXX)))", "username"=>"USER_DEV", "password"=>"XXX"}

1 个答案:

答案 0 :(得分:0)

Spring是使用错误的Oracle数据库架构的原因。与https://github.com/rails/spring/issues/305相关,例如ENV未正确加载。

我将puts Rails.env添加到我的一个初始化程序中。它始终显示development,即使我使用rails c -e production

运行bin/spring binstub --remove --all后,使用了正确的架构。

顺便说一下,初始化程序中定义的所有变量对developmenttestproduction的行为也有不同的影响。