Why does rails generate a schema.rb file even with schema format set to sql
NickName:Van_Paitin Ask DateTime:2022-08-03T12:04:51

Why does rails generate a schema.rb file even with schema format set to sql

I am running Rails 6.1.6 on ruby -v 2.7.1.

I set this in my application.rb file

config.active_record.schema_format = :sql

I tried to run my migrations but schema.rb gets generated even as the existing structure.sql file gets updated accordingly.

Extra info: I observed this behaviour when I upgraded to Rails 6.1 from 5.2.

I don't suppose schema.rb should ever be generated when schema_format is set to :sql. When I tried to set config.active_record.dump_schema_after_migration to false. My structure.sql file does not get updated.

What may I be missing or doing wrong?

Copyright Notice:Content Author:「Van_Paitin」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/73216174/why-does-rails-generate-a-schema-rb-file-even-with-schema-format-set-to-sql

More about “Why does rails generate a schema.rb file even with schema format set to sql” related questions

Why does rails generate a schema.rb file even with schema format set to sql

I am running Rails 6.1.6 on ruby -v 2.7.1. I set this in my application.rb file config.active_record.schema_format = :sql I tried to run my migrations but schema.rb gets generated even as the exis...

Show Detail

Keep both structure.sql and schema.rb up to date in rails

I'm using a postgres feature that rails schema.rb file doesn't support so I've set config.active_record.schema_format = :sql to ensure that all aspects of my database schema are recorded. However...

Show Detail

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

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: ...

Show Detail

Generate the schema.rb from Rails Models (without Database)

I have a Rails project that has an outdated schema.rb file. I also have an empty database. How do I generate the schema.rb from the Rails Models?

Show Detail

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

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/s...

Show Detail

Rails: does minitest use schema.rb to recreate the test schema?

I am trying to bring a legacy Rails system up more current standards but having problems getting the test database to reflect the state of schema.rb plus changes made via migrations. tl;dr Does ru...

Show Detail

How to reload schema.rb in rails app?

I currently have a few migrations which were created when I initially created models using rails generate model. I've run those migrations and successfully updated the database. I've then made some

Show Detail

Rails 4.2: How to generate schema.rb with inserts as well?

I want to migrate parts of my app to Rails, so I want to generate the schema.rb for my database. To do that, I simply configurate the Rails app to point to the database in question, however I have a

Show Detail

Rails: what does schema.rb do?

I used to think the db/schema.rb in a Rails project stored the database schema, so that ActiveRecord can know what table/column it has. But earlier I surprisingly noticed that my project runs norm...

Show Detail

Ruby on Rails. Why schema.rb builded on existing data through db:schema:dump is almost empty?

I am trying to find the correct (any) method to create an application in Ruby on Rails having an existing database (PostgreSQL) with data and fresh app made with: rails new --database=postgresql -...

Show Detail