Every time a run rake db:migrate
it generate as a result a useless db/schema.rb
file which can't be loaded with rake db:schema:load
simply because my views are being dumped incorrectly.
I noticed the dump is coming with my views and a table with the same name. This cause to raise an error due to a table name which already exists.
I'm currently using rails 4.2.11 and the Scenic version in my gemfile is 1.4.1.
This is a few of my tables and a view which uses them, I tried to remove all the definition for table foo_bar
(same name of the view) manually and after that the rake db:schema:load
worked. But the next time I ran a db:migration
those useless table will come again.
ActiveRecord::Schema.define(version: 2) do
create_table "foo_bar", id: false, force: :cascade do |t|
t.integer "id", limit: 4, default: 0, null: false
t.string "uuid", limit: 36
t.decimal "quantity", precision: 20, scale: 4, default: 0.0
t.integer "bar_id", limit: 4, default: 0
t.decimal "price", precision: 20, scale: 4, default: 0.0
end
create_table "foo", force: :cascade do |t|
t.string "uuid", limit: 36
t.decimal "quantity", precision: 20, scale: 4, default: 0.0
end
create_table "bar", force: :cascade do |t|
t.decimal "price", precision: 20, scale: 4, default: 0.0
t.integer "foo_id", limit: 4
t.decimal "quantity", precision: 20, scale: 4, default: 0.0
end
add_index "bar", ["foo_id"], name: "index_bars_on_foo_id", using: :btree
add_foreign_key "bar", "foo"
create_view "foo_bar", sql_definition: <<-SQL
select `s`.`id` AS `id`,`s`.`uuid` AS `uuid`,`s`.`quantity` AS `quantity`,`t`.`id` AS `bar_id`,`t`.`price` AS `price` from (`foo` `s` left join `bar` `t` on(((`t`.`foo_id` = `s`.`id`))))
SQL
end
My database is much bigger than this, and now every time I need to initiate a new app I have to run all the migrations from scratch and it takes much time and the schema:load
does not