jjzjj

code-migration

全部标签

ruby-on-rails - 添加 :on_delete to already existing foreign_key in rails migration

我已经通过这种方式在数据库中创建了外键:classCreateUser但忘记添加on_delete::nullify。迁移已被推送并用于生产。我想添加新的迁移,这将为此PK约束添加级联删除。如何实现? 最佳答案 您可以在下次迁移时删除和添加外键:classChangeForgeinKeyOnUsersTable 关于ruby-on-rails-添加:on_deletetoalreadyexistingforeign_keyinrailsmigration,我们在StackOverflow

ruby-on-rails - 有没有 "Code Complete"的 Ruby 书?

我开始阅读“代码完整”第2版这本书,但当我注意到大多数解决方案都可以使用Ruby惯用法在Ruby中轻松解决时,我停止了阅读。有没有类似的Ruby书籍?这是我开始阅读的版本:http://www.amazon.com/Code-Complete-Practical-Handbook-Construction/dp/0735619670 最佳答案 把那本书拿回来,从你离开的地方开始。作为阅读第一版并且最近以编写Ruby为生的人,我可以自信地说CodeComplete的类(class)是通用的。那本书中关于良好代码构造的智慧-质量命名、解

ruby - Rails 3 db :migrate 的未定义方法 `visitor'

我在Rails3中进行数据库迁移时遇到异常。undefinedmethod`visitor'for#编辑请查看解决方案here.在我的项目中没有出现字符串visitor所以我很困惑。这是完整的转储:$rakedb:migrate--trace**Invokedb:migrate(first_time)**Invokeenvironment(first_time)**Executeenvironment**Invokedb:load_config(first_time)**Invokerails_env(first_time)**Executerails_env**Executedb:l

ruby-on-rails - rake 数据库 :migrate not working on my postgres db

好的,所以我有一个Rails应用程序,我试图在postgres数据库上运行迁移,我通常使用mysql,一切都很好,但是当我运行命令时,我得到了这个rakedb:migrate(in/Users/tamer/Sites/my_app)/Users/tamer/.rvm/gems/ruby-1.9.2-p290@my_app/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:487:[BUG]Segmentationfaultruby1.9.2p290(2011-07-09

ruby-on-rails - rake db :migrate doesn't work after ruby 2. 2.2 到 2.2.3 通过 RVM 升级

我最近使用RVM从Ruby2.2.2升级到2.2.3。这搞砸了我的开发环境中的一些事情,但由于有用的错误消息,到目前为止我可以处理它。现在我想向我的数据库添加一些迁移,但遇到了这个错误:$rakedb:migrate/Users/howard/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in`eval':/Users/howard/.rvm/rubies/ruby-2.2.3/bin/rake:4:syntaxerror,unexpectedtSTRING_BEG,expectingkeyword_door'{'or'('(Syn

ruby - 数据库 :migrate hangs on simple migration

我正在使用PostgreSQL、Rails3.1.3和Ruby1.9.3。我正在努力使用db:migrate概述here.这是我在终端中看到的:funkdified@funkdified-laptop:~/railsprojects/hartl$bundleexecrakedb:migrate--trace**Invokedb:migrate(first_time)**Invokeenvironment(first_time)**Executeenvironment**Invokedb:load_config(first_time)**Invokerails_env(first_tim

ruby - 带有删除表的 rake db :migrate updating schema. rb

我在git上有几个分支,跨这些分支的模式在不同的版本上。切换到分支后,让我们说new_feature(有挂起的迁移)如果我做rakedb:setup然后它建议我运行挂起的迁移。一旦我这样做,我的架构就会更新为在同一分支中删除的表。如果我执行rakedb:reset然后它工作正常。我知道db:setup和db:reset之间的区别。后者执行db:drop然后执行db:setup但我想知道为什么架构会在rakedb:migrate上显示那些删除的表我肯定缺少一些Rails知识w.r.t.模式加载和迁移过程任何见解都会有很大帮助。提前致谢 最佳答案

ruby - 使用 :sql 模式格式时如何使 rake db :migrate generate schema. rb

如果在config/application.rb中使用这个选项:config.active_record.schema_format=:sql然后当你这样做时:rakedb:migrate它只转储db/structure.sql。我知道它没有使用db/schema.rb因为它使用的是:sql选项,但是你如何制作rakedb:migrate还生成db/schema.rb吗?我们需要它,因为RubyMine4.5和IntelliJIDea11使用db/schema.rb来自动完成列。 最佳答案 要生成/更新db/schema.rb,即使

ruby - 为什么在 Ruby 中使用类变量被视为 'code smell' ?

根据Reek,创建类变量被认为是“代码味道”。这背后的解释是什么? 最佳答案 您可以在他们关于ClassVariables的文档中找到:Classvariablesformpartoftheglobalruntimestate,andassuchmakeiteasyforonepartofthesystemtoaccidentallyorinadvertentlydependonanotherpartofthesystem.Sothesystembecomesmorepronetoproblemswherechangingsomet

ruby-on-rails - 数据库错误 :Migrate "uninitialized constant DeviseCreateUsers"

我试图在Heroku上运行rakedb:migrate命令,但遇到了这个问题。uninitializedconstantDeviseCreateUsers/app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.11/lib/active_support/inflector/methods.rb:230:in`blockinconstantize'/app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.11/lib/active_support/inflector/methods.rb:2