documentcloud / documentcloud

The DocumentCloud platform
https://www.documentcloud.org
MIT License
424 stars 162 forks source link

DB Migration error - RegenerateThumbnails #116

Closed drulang closed 10 years ago

drulang commented 10 years ago

I'm trying to setup a development environment but am running into a db migration error. The development env readme doesn't mention having to do a migration, but when I navigate to the index it informs me to run the following command:

rake db:migrate RAILS_ENV=development

Console output:

OmniAuth secrets are not available.  Not performing initialization
== 20100114170350 RegenerateThumbnails: migrating =============================
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

wrong number of arguments (1 for 0)/opt/documentcloud/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/scoping/named.rb:24:in `all'
/opt/documentcloud/db/migrate/20100114170350_regenerate_thumbnails.rb:7:in `up'
/opt/documentcloud/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:558:in `up'
/opt/documentcloud/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:598:in `exec_migration'
/opt/documentcloud/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:579:in `block (2 levels) in migrate'
/opt/documentcloud/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:578:in `block in migrate'
/opt/documentcloud/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:294:in `with_connection'
/opt/documentcloud/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:577:in `migrate'
/opt/documentcloud/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:752:in `migrate'
/opt/documentcloud/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:992:in `block in execute_migration_in_transaction'
/opt/documentcloud/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:1038:in `block in ddl_transaction'
/opt/documentcloud/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `block in transaction'
/opt/documentcloud/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/database_statements.rb:219:in `within_new_transaction'
/opt/documentcloud/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `transaction'
/opt/documentcloud/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/transactions.rb:208:in `transaction'
/opt/documentcloud/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:1038:in `ddl_transaction'
/opt/documentcloud/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:991:in `execute_migration_in_transaction'
/opt/documentcloud/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:953:in `block in migrate'
/opt/documentcloud/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:949:in `each'
/opt/documentcloud/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:949:in `migrate'
/opt/documentcloud/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:807:in `up'
/opt/documentcloud/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/migration.rb:785:in `migrate'
/opt/documentcloud/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/railties/databases.rake:34:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
nathanstitt commented 10 years ago

Hi @drulang. Thanks very much for taking the time to bring this to our attention. We're discussing a pull request to fix this in #111

The cause stems from our migrations being outdated and calling methods on code that no longer exists or has changed. We hope to have it resolved soon.

I'll close this issue for now in favor tracking it in the pre-existing issue #111. If you disagree please re-open and let us know what we can do.

drulang commented 10 years ago

Hey @nathanstitt I think that's totally fine. I was looking at that ticket. So is the workaround to use the code at https://github.com/nathanstitt/documentcloud/compare/migration_rollup? Or use an older version of rails?

Thanks!

nathanstitt commented 10 years ago

Yes, we've got two approaches we can go with on fixing the migrations.

We can either use Adam Hooper's PR (#111) to fix the old migrations so they run, or we just remove them and use the rollup approach.

knowtheory commented 10 years ago

After a quick powwow, we'll move the migrations into a dir w/ a readme for historical purposes, and then just stick a rollup migration in for folks to use.

nathanstitt commented 10 years ago

@drulang I've just pushed up a change to the migrations that combines them all into one large migration that encodes what the db schema should look like.

When you're able to, please give the code a try and it should work better for you.

Thanks again for brining the issue to our attention!

drulang commented 10 years ago

Hey @nathanstitt, thanks for the quick actions. I just went through a fresh install and hit the error below. I'm using postgresql 8.4, ruby 1.9.3, and the latest version of documentcloud. Any thoughts? I'll keep researching

Error:

OmniAuth secrets are not available.  Not performing initialization
== 1 InitialMigration: migrating ==============================================
-- enable_extension("plpgsql")
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::SyntaxError: ERROR:  syntax error at or near "EXTENSION"
LINE 1: CREATE EXTENSION IF NOT EXISTS "plpgsql"
               ^
: CREATE EXTENSION IF NOT EXISTS "plpgsql"/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:815:in `async_exec'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:815:in `block in exec_no_cache'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:373:in `block in log'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activesupport-4.1.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:367:in `log'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:815:in `exec_no_cache'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:137:in `exec_query'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:663:in `enable_extension'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/migration.rb:649:in `block in method_missing'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/migration.rb:621:in `block in say_with_time'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/migration.rb:621:in `say_with_time'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/migration.rb:641:in `method_missing'
/home/dru/documentcloud/db/migrate/1_initial_migration.rb:9:in `change'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/migration.rb:595:in `exec_migration'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/migration.rb:579:in `block (2 levels) in migrate'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/migration.rb:578:in `block in migrate'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:294:in `with_connection'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/migration.rb:577:in `migrate'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/migration.rb:752:in `migrate'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/migration.rb:992:in `block in execute_migration_in_transaction'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/migration.rb:1038:in `block in ddl_transaction'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `block in transaction'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/database_statements.rb:219:in `within_new_transaction'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `transaction'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/transactions.rb:208:in `transaction'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/migration.rb:1038:in `ddl_transaction'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/migration.rb:991:in `execute_migration_in_transaction'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/migration.rb:953:in `block in migrate'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/migration.rb:949:in `each'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/migration.rb:949:in `migrate'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/migration.rb:807:in `up'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/migration.rb:785:in `migrate'
/home/dru/documentcloud/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.1/lib/active_record/railties/databases.rake:34:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
knowtheory commented 10 years ago

postgres 8.4 is not going to cut it, you'll need postgres 9.2 or greater.

drulang commented 10 years ago

I should have googled first. It's a little confusing because postgress 8.4 is referenced in the INSTALL file. Thanks @knowtheory

knowtheory commented 10 years ago

Oh, thanks for pointing that out, we'll update it.

nathanstitt commented 10 years ago

Like @knowtheory said, you'll need a more recent Postgresql. Something else that could also trip you up later is installing the extensions.

You'll need either the database login to be a superuser, or the needed extensions pre-installed in the database. You can do so as a superuser by executing:

CREATE EXTENSION IF NOT EXISTS "plpgsql";
CREATE EXTENSION IF NOT EXISTS "hstore";

If the database login is a super-user, then the migration should execute fine though.

drulang commented 10 years ago

Awesome guys I really appreciate the help. So I finally got it up an running! I ran into one issue where the migration complained about 'hstore already exists' so I removed the 'enable_extension "hstore"'' line and the migration went through. This may be unique to my env though

nathanstitt commented 10 years ago

Hm, that line should have ran a "create if not exists" type of statement and proceeded even if it was already present. I'll have to test that out further. Glad it's working for you now though!