Questions tagged [schema.rb]
25 questions
52
votes
9 answers
What is the preferred way to manage schema.rb in git?
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…

Otto
- 18,761
- 15
- 56
- 62
24
votes
7 answers
Rails: I update migration file then run db:migrate, but my schema isn't updating
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…

Evolve
- 8,939
- 12
- 51
- 63
16
votes
3 answers
schema.rb messed up due to migrations in other branches
Currently I'm working with a huge rails application and multiple branches with each a new feature for this application.
It happens a lot a feature will require migrations, which shouldn't be a problem until you merge it with master: schema.rb got…

Vikko
- 1,396
- 10
- 23
10
votes
2 answers
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/schema.rb since it is using the :sql option, but how…

Gary S. Weaver
- 7,966
- 4
- 37
- 61
9
votes
3 answers
Should I flatten Rails migrations?
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?

jes5199
- 18,324
- 12
- 36
- 40
6
votes
1 answer
How to make Rails generate 'schema.rb' with bigint support for MySQL?
I am using Rails 3.0.5. I am using MySQL as a database storage. I have a model in which one of the columns needs to be BIGINT. I am using the following in my create migration file:
t.column :my_column_name, :bigint
which works fine.
However,…

p.matsinopoulos
- 7,655
- 6
- 44
- 92
6
votes
2 answers
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:
# use structure.sql, not…

Doug
- 176
- 1
- 9
6
votes
2 answers
How can I recreate Schema.rb (after deleting) in Ruby on Rails?
I deleted my Schema.rb by mistake (sort of) and I can't seem to be able to regenerate it into db/ by using rake db:dump, I don't really know what to do at this point.
Some suggested
rake db:dump:all
rake db:create:all
rake db:migrate
Nothing worked.…

Jason Procka
- 305
- 1
- 6
- 13
5
votes
1 answer
Can I Rebuild db/schema.rb to Include Multiple Databases Without Migrations?
I have a Rails 5 application that uses three different existing databases. No migrations were needed in this application. I want to build db/schema.rb to include all three databases, not just the main database. Executing rake db:schema:dump rebuilds…

Pamela Cook - LightBe Corp
- 3,912
- 5
- 50
- 86
3
votes
1 answer
How do I re-order table columns in a Rails app?
I created a model in my Rails app and realized after some time that I had forgotten to add some attributes, and later added them via a generated migration.
I now realize that the order of the attribute columns in schema.rb is the order that they…

dbate
- 127
- 13
3
votes
1 answer
Capistrano deploy and schema.rb
I'm a newbie in Rails and I'm trying to deploy my first project.
I'm using rails 3, ruby 1.8.7, Passanger, Mysql and Git
I followed a lot of tutorials to learn about deploying with capistrano and there is a question that i can't figure out.
In the…

tbem
- 595
- 4
- 14
2
votes
1 answer
Is it possible to have same index name within a sqlite database?
I have a Ruby on Rails app and development database is in Mysql. I decided to do use sqlite database for testing. To accomplish that, I did the following:
Configured database.yml file to support test.sqlite3 for testing environment
Took a dump of…

Sriharsha
- 111
- 1
- 8
1
vote
2 answers
In Ruby on Rails with the Foreigner Gem/Plugin, should the foreign key setup be visible in Schema.rb?
I am developing a Ruby on Rails application, and using the foreigner plugin to set up foreign key constraints in the migrations for example like this.
add_foreign_key(:notifications, :invitations, :dependent => :delete)
However, when I run the…

Ross
- 1,551
- 14
- 15
1
vote
4 answers
Viewing the contents of tables in schema.rb in rails
I'm sorry if this is a stupid question, but in my schema.rb I have several tables like
create_table "messages", :force => true do |t|
t.integer "user_id", :null => false
t.string "message", :null => false
…

user852974
- 2,242
- 10
- 41
- 65
1
vote
1 answer
Rake db:setup does not run rails db:migrate, schema.rb does not exist error
On Rails 6, i expect rake db:setup to perform db:create, db:migrate and db:seed
i have only one data model and the record creation for its table was written in db/seeds.rb
# db/seeds.rb
require 'csv'
csv_text = File.read(Rails.root.join('lib',…

Ridhwaan Shakeel
- 981
- 1
- 20
- 39