Open h0jeZvgoxFepBQ2C opened 10 years ago
Are you getting this when trying to develop something for queue_classic_admin or when using it in your project? Just to be sure.
If this is in one of your app, which is what I assume, how do you proceed to get it installed?
I also got this same weird error in a Rails 4.2 app in my development environment. I was able to get the migrations to run on my test environment by recreating the test database with RAILS_ENV=test rake db:drop db:create db:migrate
. Then to get past it for development, I just deleted the migrations because I don't use queue_classic-later.
Interesting. If you could give some repro steps or app, it would be great.
Sure, the main thing is you need to have some migrations that already exist in the database. Starting from a fresh database doesn't seem to trigger it. Here's some exact repro steps:
git clone https://github.com/abevoelker/queue_classic_admin-bugrepro.git
cd queue_classic_admin-bugrepro
bundle
rake db:create db:migrate
rake queue_classic_admin:install:migrations
rake db:migrate
I don't know if it would fix it or not, but if it's the ActiveRecord::Base.connection.table_exists?
that is causing the problem, you could do a raw SQL migration with execute
and check for existence of the table in the actual SQL. If you're relying on a Postgres version >= 9.2 (which I think you are, due to the json
data type), then the ALTER TABLE IF EXISTS
syntax that was introduced in 9.2 may be useful.
Hey,
I don't have too much experience with Queue Classic. Hope not to be misleading. The error doesn't seem to be related to SQL and just to the mere fact that the migration is duplicated. The rake task copies the files to the rails application migration folder. Also, exists an initializer in /lib/queue_classic_admin/engine.rb that adds the migrations of this folder to the app folder.
Aren't this two steps somehow incompatible?. When applying the migrations, rails will look in this two places, the rails application migrations folder and also the gem migrations folder, throwing the error. Pretty sure that I'm missing something, but I'd be very grateful if somebody can help me to understand better.
Thanks to @abevoelker for the repro steps.
I ran into the same issue with Rails 7. What's interesting is that once the queue_classic_admin gem is installed, rake db:migrate fails. That is without calling the rake task. I'm guessing that the duplication is self inflicted. The install rake task copies the internal AddIdToLater migration to the local migration directory. For some reason the source directory is also in the path for possible migration files.
bundle install # remove queue_classic_admin gem
db:migrate # works
bundle install # add queue_classic_admin gem
db:migrate # fails
rake aborted!
StandardError: Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Active Record release the migration was written for:
class AddIdToLater < ActiveRecord::Migration[7.0]
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:561:in `inherited'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/queue_classic_admin-0.0.13/db/migrate/20130626182618_add_id_to_later.rb:1:in `<main>'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1056:in `load'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1056:in `load_migration'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1050:in `migration'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1046:in `disable_ddl_transaction'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1418:in `use_transaction?'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1365:in `rescue in execute_migration_in_transaction'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1353:in `execute_migration_in_transaction'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1333:in `each'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1333:in `migrate_without_lock'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1282:in `block in migrate'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1432:in `block in with_advisory_lock'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1447:in `with_advisory_lock_connection'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1428:in `with_advisory_lock'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1282:in `migrate'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1117:in `up'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1092:in `migrate'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/tasks/database_tasks.rb:262:in `migrate'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/railties/databases.rake:92:in `block (2 levels) in <main>'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
Caused by:
StandardError: Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Active Record release the migration was written for:
class AddIdToLater < ActiveRecord::Migration[7.0]
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:561:in `inherited'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/queue_classic_admin-0.0.13/db/migrate/20130626182618_add_id_to_later.rb:1:in `<main>'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1056:in `load'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1056:in `load_migration'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1050:in `migration'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1046:in `disable_ddl_transaction'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1418:in `use_transaction?'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1410:in `ddl_transaction'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1359:in `execute_migration_in_transaction'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1333:in `each'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1333:in `migrate_without_lock'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1282:in `block in migrate'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1432:in `block in with_advisory_lock'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1447:in `with_advisory_lock_connection'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1428:in `with_advisory_lock'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1282:in `migrate'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1117:in `up'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1092:in `migrate'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/tasks/database_tasks.rb:262:in `migrate'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.0.3.1/lib/active_record/railties/databases.rake:92:in `block (2 levels) in <main>'
/Users/johnkolen/.rvm/gems/ruby-3.0.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
Tasks: TOP => db:migrate
Hey,
I'm using the support-v2 branch, creating the migrations for a rails 3.2.20 app.
Creation works fine, but migrating doesnt work: I dont use the queue-classic-later gem and there are no duplicate migrations with this names.. but i still get this exception:
Any hints?