简体   繁体   English

运行Ruby on Rails迁移,已更新schema.rb,但更改未反映在psql数据库中

[英]Ruby on Rails migrations run, schema.rb updated but changes not reflecting in psql database

I have a ruby on rails application already running in production. 我有一个已在生产中运行的ruby on rails应用程序。 The database has records which I do not want to loose. 数据库中有我不想丢失的记录。 I had to add and run new migrations to add some new columns to existing tables. 我必须添加并运行新的迁移,才能向现有表中添加一些新列。 The migrations run successfully and the schema.rb file reflects the changes but the changes do not appear in the database or existing table structure. 迁移成功运行,schema.rb文件反映了更改,但更改未出现在数据库或现有表结构中。

Based on research online, rake db:schema:load updates the db based on the schema.rb file. 根据在线研究, rake db:schema:load基于schema.rb文件更新数据库。 But this resets the database. 但这会重置数据库。

It is crucial that I do not loose the data in the tables.Is there any way to solve this? 我不要丢失表中的数据至关重要,有什么办法可以解决这个问题? I am fairly new to ruby on rails. 我是红宝石的新手。

I was able to fix it. 我能够解决它。 I checked the status of migrations in the production environment rake db:migrate:status RAILS_ENV=production and realised they were down. 我在生产环境rake db:migrate:status RAILS_ENV=production检查了rake db:migrate:status RAILS_ENV=production并意识到它们已关闭。 I then run rake db:migrate RAILS_ENV=production and that did it. 然后,我运行rake db:migrate RAILS_ENV=production ,然后执行此操作。 Changes now reflect in the db. 现在,更改将反映在数据库中。 Thanks @muistooshort for the nudge in the right direction 感谢@muistooshort朝着正确的方向前进

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM