Rails 5.1.4 after upgrade DuplicateMigrationNameError - ruby-on-rails

I recently updated a Rails 4.2 app to 5.1.4. After upgrading, whenever I try to run rake db:migrate, I get a DuplicateMigrationNameError. The first few times, the error pointed to a file so I just changed the name of the migration class and the file name. But after 4 such changes, the rake task threw the error for the file I just changed, with the new file name/class name. If I changed it back, it still threw the same error. If I changed it to something totally new the same thing happened; it picked up the new filename and threw a DuplicateMigrationNameError. I do not have a duplicate file, there are no cached files that I can find. I am running the rails app in a vagrant vm running ubuntu 16.04. The migrations all ran fine on rails 4.2.

This can also happen when the class name of the migration is duplicated. Open the migrations and see if the class names are identical.

Related

rails db migrate locally-Multiple migrations have the version number

I'm using docker, and I'm trying to run migrations locally using
docker-compose run app rails db:migrate
I'm getting an error though:
Multiple migrations have the version number 20211230114441.
I tried searching for this migration in db/migrate but nothing's there. I also tried checking out different versions of schema.rb but this fixed nothing.
Since I'm running using docker, and even though, my files are attached to a volume, I tried using docker-compose build before running again to make sure that the migration files are udpated. Again fixed nothing.
Any ideas on how this can be fixed?

Rails 6.1 failed migrations no longer block rails from running?

In the past when there were migrations which didn't run yet, there would be an error 'pending migrations' that would prohibit rails (server, console) from starting.
I've updated to Rails 6.1 and have a failing migration. Nevertheless the server is running and I can go into the console without any warning.
The migration that is failing is a ActiveRecord::Migration[6.1] migration.
Is this intended? Is there a way of going back to the old behavior? We use Kubernetes and a failed migration just blocks the new pod from coming live which is perfect.

issues with schema.rb file during rails 5 upgrade

After upgrading to Rails 5, I receive an error message like following every time I try to load from schema (set up a new computer on the app, run rails db:test:prepare before running tests, etc.):
ActiveRecord::StatementInvalid: PG::UndefinedObject: ERROR: type "serial" does not exist
LINE 1: SELECT 'serial'::regtype::oid
Searching around isn't yielding much help. The most relevant thread is this one: https://github.com/rails/rails/issues/30298 but I am not trying to run any new migrations, nor does the schema_plus_indexes gem seem to have anything to do with the issue (the two issues described in that thread).
In our case, we don't keep migration files around after they have been run against all databases. Because of this, when working on the upgrade to rails 5, there were 0 migration files present. The issue, it seems, is that rails will only automatically "fix" your schema.rb file for you if you are actually running a migration file (even trying rails db:migrate with no migration files present won't work).
The solution, for us, was to create a blank migration and run rails db:migrate in order to get the schema.rb file properly formatted.

Rails - Cant run any rake commands db is messed up

Everything was working fine yesterday and all of a sudden when i tried to run my server or run any rake tasks i get this error
Mysql2::Error: Table 'myapp_development.key_value_stores' doesn't exist: SHOW FULL FIELDS FROM `key_value_stores`
I've tried google searching and searching on stackoverflow all morning and cant find a solution to this
Try to rollback your migration file (take backup of the migration file will help while creating new ),
rake db:migrate:down VERSION=migrations's_version
and then try to restart the rails server.If you face same problem then with same migration number search in schema_migrations table in database delete that record and make new migration again.
I was struggling with this for a while but what i ended up doing
update xcode and update command line tools
uninstall then install mysql via homebrew
then i ended up manually removing my database folder in
usr/local/var/mysql/myapp
then i did a
rake:create
and then i just pulled my production database and copied it to my development database
rake db:backup_and_load
then I was up and running again
dont know which one of that fixed it specifically but thats what i did

How do I change a Ruby on Rails (4) application name?

Essentially I have a basic app that I would like to use as base for my other projects.
I ran git clone git#site.org:user/app.git newfolder
But when I run my rails app rails s I get the following error:
Migrations are pending; run 'rake db:migrate RAILS_ENV=development' to resolve this issue.
So I run rake db:migrate and start the app again, getting the following error:
I have a sneaking suspicion that it has something to do with the app name as asked in this question but I noticed the solution was provided for Rails 3 and the GitHub project hasn't been updated in two years.
Essentially, I think I have a solution (renaming the app) but I don't know how to do that. However, I may be wrong and I don't know why I am getting this error?
You are getting this error because, one of the css files you are requiring in your application.css is requiring application.css. Go through all the file in your app/assets/stylesheets and make sure that none of the file that is required in application.css is requiring application.css.

Resources