schema.rb

In Rails 5, setting config.active_record.schema_format = :sql but still getting schema.rb created on db:migrate

浪尽此生 提交于 2020-05-15 04:33:46
问题 Working on a Rails 5 app, I want to use structure.sql instead of schema.rb (we're using PostGIS with lots of custom SQL calls...). In config/initializers/database_options.rb I have the following: # use structure.sql, not schema.rb Rails.application.config.active_record.schema_format = :sql If I run the following: $ rake db:migrate it generates db/schema.rb , not db/structure.sql . The rails guides say: There are two ways to dump the schema. This is set in config/application.rb by the config

In Rails 5, setting config.active_record.schema_format = :sql but still getting schema.rb created on db:migrate

[亡魂溺海] 提交于 2020-05-15 04:33:20
问题 Working on a Rails 5 app, I want to use structure.sql instead of schema.rb (we're using PostGIS with lots of custom SQL calls...). In config/initializers/database_options.rb I have the following: # use structure.sql, not schema.rb Rails.application.config.active_record.schema_format = :sql If I run the following: $ rake db:migrate it generates db/schema.rb , not db/structure.sql . The rails guides say: There are two ways to dump the schema. This is set in config/application.rb by the config

Should I flatten Rails migrations?

浪子不回头ぞ 提交于 2019-12-30 08:16:47
问题 It's possible to replace db/migrate/* with the contents of db/schema.rb, so that you only have one migration step. Do any of you ever do this? Why? 回答1: Why would you want to do this? You could just run rake db:schema:load if you don't want to run all migrations. Migrations are used not (only) to initialize a new database, but to migrate it to another version. 回答2: Also, some big Ruby on Rails kit packages (like that one that's slipping my mind now that lets you set up an ecommerce site in

Should I flatten Rails migrations?

南楼画角 提交于 2019-12-30 08:16:13
问题 It's possible to replace db/migrate/* with the contents of db/schema.rb, so that you only have one migration step. Do any of you ever do this? Why? 回答1: Why would you want to do this? You could just run rake db:schema:load if you don't want to run all migrations. Migrations are used not (only) to initialize a new database, but to migrate it to another version. 回答2: Also, some big Ruby on Rails kit packages (like that one that's slipping my mind now that lets you set up an ecommerce site in

How to make rake db:migrate generate schema.rb when using :sql schema format

十年热恋 提交于 2019-12-19 05:24:11
问题 If using the this option in config/application.rb : config.active_record.schema_format = :sql then when you do: rake db:migrate it only dumps the db/structure.sql . I know it isn't using the db/schema.rb since it is using the :sql option, but how can you make rake db:migrate generate db/schema.rb also? We need that because RubyMine 4.5 and IntelliJ IDea 11 use db/schema.rb for autocompletion of columns. 回答1: To generate/update db/schema.rb even if using the :sql option, you can put this in

Should I flatten Rails migrations?

时间秒杀一切 提交于 2019-12-01 03:47:18
It's possible to replace db/migrate/* with the contents of db/schema.rb, so that you only have one migration step. Do any of you ever do this? Why? Why would you want to do this? You could just run rake db:schema:load if you don't want to run all migrations. Migrations are used not (only) to initialize a new database, but to migrate it to another version. Also, some big Ruby on Rails kit packages (like that one that's slipping my mind now that lets you set up an ecommerce site in your Rails app), flatten their migrations. I've also known of projects with a ton of migrations to do this every

How to make rake db:migrate generate schema.rb when using :sql schema format

半城伤御伤魂 提交于 2019-12-01 03:44:43
If using the this option in config/application.rb : config.active_record.schema_format = :sql then when you do: rake db:migrate it only dumps the db/structure.sql . I know it isn't using the db/schema.rb since it is using the :sql option, but how can you make rake db:migrate generate db/schema.rb also? We need that because RubyMine 4.5 and IntelliJ IDea 11 use db/schema.rb for autocompletion of columns. To generate/update db/schema.rb even if using the :sql option, you can put this in your Rakefile : Rake::Task["db:migrate"].enhance do if ActiveRecord::Base.schema_format == :sql Rake::Task["db

Rails: I update migration file then run db:migrate, but my schema isn't updating

☆樱花仙子☆ 提交于 2019-11-30 11:25:55
问题 I'm trying to add an extra field to one of my tables. I've added the field in the migration file (under db\migrate), then ran 'rake db:migrate' which ran without troubles. My text editor even told me my schema.db file has been updated and needs to refresh. The schema file does not contain my new field and any attempts to reference the field from my views fail miserably. How do I do this? It is possible to update a table with an extra field via rails without having to totally drop and recreate

Rails: I update migration file then run db:migrate, but my schema isn't updating

拥有回忆 提交于 2019-11-30 00:11:19
I'm trying to add an extra field to one of my tables. I've added the field in the migration file (under db\migrate), then ran 'rake db:migrate' which ran without troubles. My text editor even told me my schema.db file has been updated and needs to refresh. The schema file does not contain my new field and any attempts to reference the field from my views fail miserably. How do I do this? It is possible to update a table with an extra field via rails without having to totally drop and recreate the database again? utapyngo http://guides.rubyonrails.org/migrations.html#changing-existing

What is the preferred way to manage schema.rb in git?

為{幸葍}努か 提交于 2019-11-27 07:44:57
I don't want to add schema.rb to .gitignore , because I want to be able to load a new database schema from that file. However, keeping it checked in is causing all sorts of spurious conflicts that are easily resolved by a fresh db:migrate:reset . Basically I want a way to: Keep schema.rb in the repository for deploy-time database setup Keep schema.rb in '.gitignore' for general development There would be one or two people responsible for updating schema.rb and knowing that it was correct. Is there a way I can have my cake and eat it, too? What has worked really well for me is to delete and