Project

General

Profile

Actions

Defect #8178

closed

SQLite3::CantOpenException: unable to open database file: DROP TABLE "issue_histories"

Added by Jon Lambert about 14 years ago. Updated about 14 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Database
Target version:
-
Start date:
2011-04-18
Due date:
% Done:

0%

Estimated time:
Resolution:
Duplicate
Affected version:

Description

Failure in DB migration during installation

About your application's environment
Ruby version 1.8.7 (i386-cygwin)
RubyGems version 1.4.2
Rack version 1.0
Rails version 2.3.5
Active Record version 2.3.5
Active Resource version 2.3.5
Action Mailer version 2.3.5
Active Support version 2.3.5
Edge Rails revision unknown
Application root /c/www/redmine-1.1.2
Environment production
Database adapter sqlite3
Database schema version 6

$ sqlite3 --version
3.7.3

$ gem list sqlite3

  • LOCAL GEMS ***
    sqlite3 (1.3.3)
    sqlite3-ruby (1.3.3, 1.3.2, 1.2.5)

database.yml
production:
adapter: sqlite3
database: db/prod.db

development:
adapter: sqlite3
database: db/dev.db

test:
adapter: sqlite3
database: db/test.db

Error during migration:

$ RAILS_ENV=production rake db:migrate
(in /c/www/redmine-1.1.2)
Setup: migrating ========================================================
<snip>
CreateJournals: migrating ===============================================
-- create_table(:journals, {:force=>true})
> 0.0090s
-
create_table(:journal_details, {:force=>true})
> 0.0050s
-
add_index("journals", ["journalized_id", "journalized_type"], {:name=>"journals_journalized_id"})
> 0.0010s
-
add_index("journal_details", ["journal_id"], {:name=>"journal_details_journal_id"})
> 0.0020s
-
drop_table(:issue_histories)
rake aborted!
An error has occurred, this and all later migrations canceled:

SQLite3::CantOpenException: unable to open database file: DROP TABLE "issue_histories"


Related issues

Has duplicate Redmine - Defect #8182: SQLite3::CantOpenException: unable to open database file: DROP TABLE "issue_histories"Closed2011-04-19

Actions
Actions #1

Updated by Etienne Massip about 14 years ago

What version are you migrating from ?

Check if you have such a issue_histories table in your db, and if not, create an empty one or simply remove temporarily the drop statement from the migration file (db/migrate/007_create_journals.rb) ?

And run rake command with --trace flag.

Actions #2

Updated by Jon Lambert about 14 years ago

I'm following the new installation instructions, not trying to update.

Before I issue the command...

RAILS_ENV=production rake db:migrate

...no prod.db exists.

After the the command crashes as above in the 007_create_journals.rb, I examine the database with the sqlite.exe utility, I can verify there is indeed a 'issue_histories' table. If I reissue the command...

RAILS_ENV=production rake db:migrate

... it restarts with 007_create_journals.rb and fails again in the drop table code.

I can manually drop the table with the sqlite.exe utility, so that's not the problem.
Also I was not executing the sqlite.exe utility nor any other process that may have held the database open, so that's not the problem either.

Actions #3

Updated by Jon Lambert about 14 years ago

I'm following the new installation instructions, not trying to update.

Before I issue the command...

RAILS_ENV=production rake db:migrate

...no prod.db exists.

After the the command crashes as above in the 007_create_journals.rb, I examine the database with the sqlite.exe utility, I can verify there is indeed a 'issue_histories' table. If I reissue the command...

RAILS_ENV=production rake db:migrate

... it restarts with 007_create_journals.rb and fails again in the drop table code.

I can manually drop the table with the sqlite.exe utility, so that's not the problem.
Also I was not executing the sqlite.exe utility nor any other process that may have held the database open, so that's not the problem either.

Deleting the prod.db database and rerunning with --trace
Here's the output.

$ RAILS_ENV=production rake db:migrate --trace
(in /c/www/redmine-1.1.2)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
==  Setup: migrating ==========================================================
-- create_table("attachments", {:force=>true})
   -> 0.1290s
-- create_table("auth_sources", {:force=>true})
   -> 0.0020s
-- create_table("custom_fields", {:force=>true})
   -> 0.0030s
-- create_table("custom_fields_projects", {:force=>true, :id=>false})
   -> 0.0010s
-- create_table("custom_fields_trackers", {:force=>true, :id=>false})
   -> 0.0020s
-- create_table("custom_values", {:force=>true})
   -> 0.0020s
-- create_table("documents", {:force=>true})
   -> 0.0030s
-- add_index("documents", ["project_id"], {:name=>"documents_project_id"})
   -> 0.0010s
-- create_table("enumerations", {:force=>true})
   -> 0.0010s
-- create_table("issue_categories", {:force=>true})
   -> 0.0010s
-- add_index("issue_categories", ["project_id"], {:name=>"issue_categories_project_id"})
   -> 0.0010s
-- create_table("issue_histories", {:force=>true})
   -> 0.0020s
-- add_index("issue_histories", ["issue_id"], {:name=>"issue_histories_issue_id"})
   -> 0.0010s
-- create_table("issue_statuses", {:force=>true})
   -> 0.0020s
-- create_table("issues", {:force=>true})
   -> 0.0050s
-- add_index("issues", ["project_id"], {:name=>"issues_project_id"})
   -> 0.0000s
-- create_table("members", {:force=>true})
   -> 0.0030s
-- create_table("news", {:force=>true})
   -> 0.0030s
-- add_index("news", ["project_id"], {:name=>"news_project_id"})
   -> 0.0000s
-- create_table("permissions", {:force=>true})
   -> 0.1350s
-- create_table("permissions_roles", {:force=>true, :id=>false})
   -> 0.0020s
-- add_index("permissions_roles", ["role_id"], {:name=>"permissions_roles_role_id"})
   -> 0.0010s
-- create_table("projects", {:force=>true})
   -> 0.0040s
-- create_table("roles", {:force=>true})
   -> 0.0030s
-- create_table("tokens", {:force=>true})
   -> 0.0020s
-- create_table("trackers", {:force=>true})
   -> 0.0020s
-- create_table("users", {:force=>true})
   -> 0.0050s
-- create_table("versions", {:force=>true})
   -> 0.0030s
-- add_index("versions", ["project_id"], {:name=>"versions_project_id"})
   -> 0.0010s
-- create_table("workflows", {:force=>true})
   -> 0.0030s
==  Setup: migrated (0.4130s) =================================================

==  IssueMove: migrating ======================================================
==  IssueMove: migrated (0.0130s) =============================================

==  IssueAddNote: migrating ===================================================
==  IssueAddNote: migrated (0.0050s) ==========================================

==  ExportPdf: migrating ======================================================
==  ExportPdf: migrated (0.0080s) =============================================

==  IssueStartDate: migrating =================================================
-- add_column(:issues, :start_date, :date)
   -> 0.0030s
-- add_column(:issues, :done_ratio, :integer, {:null=>false, :default=>0})
   -> 0.0010s
==  IssueStartDate: migrated (0.0040s) ========================================

==  CalendarAndActivity: migrating ============================================
==  CalendarAndActivity: migrated (0.0190s) ===================================

==  CreateJournals: migrating =================================================
-- create_table(:journals, {:force=>true})
   -> 0.0070s
-- create_table(:journal_details, {:force=>true})
   -> 0.0030s
-- add_index("journals", ["journalized_id", "journalized_type"], {:name=>"journals_journalized_id"})
   -> 0.0030s
-- add_index("journal_details", ["journal_id"], {:name=>"journal_details_journal_id"})
   -> 0.0010s
-- drop_table(:issue_histories)
rake aborted!
An error has occurred, this and all later migrations canceled:

SQLite3::CantOpenException: unable to open database file: DROP TABLE "issue_histories" 
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:219:in `log'
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:172:in `execute'
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:417:in `catch_schema_changes'
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:172:in `execute'
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:187:in `drop_table'
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/migration.rb:352:in `send'
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/migration.rb:352:in `method_missing'
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/migration.rb:328:in `say_with_time'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/migration.rb:328:in `say_with_time'
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/migration.rb:348:in `method_missing'
./db/migrate//007_create_journals.rb:37:in `up_without_benchmarks'
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/migration.rb:282:in `send'
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/migration.rb:282:in `migrate'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/migration.rb:282:in `migrate'
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/migration.rb:365:in `__send__'
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/migration.rb:365:in `migrate'
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/migration.rb:486:in `migrate'
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/migration.rb:560:in `call'
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/migration.rb:560:in `ddl_transaction'
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction'
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/transactions.rb:182:in `transaction'
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/migration.rb:560:in `ddl_transaction'
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/migration.rb:485:in `migrate'
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/migration.rb:472:in `each'
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/migration.rb:472:in `migrate'
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/migration.rb:400:in `up'
/c/www/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/migration.rb:383:in `migrate'
/c/www/redmine-1.1.2/vendor/rails/railties/lib/tasks/databases.rake:116
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19

Actions #4

Updated by jkjkhi gtyuyu about 14 years ago

Jon Lambert wrote:

Failure in DB migration during installation

About your application's environment
Ruby version 1.8.7 (i386-cygwin)
RubyGems version 1.4.2
Rack version 1.0
Rails version 2.3.5
Active Record version 2.3.5
Active Resource version 2.3.5
Action Mailer version 2.3.5
Active Support version 2.3.5
Edge Rails revision unknown
Application root /c/www/redmine-1.1.2
Environment production
Database adapter sqlite3
Database schema version 6

$ sqlite3 --version
3.7.3

$ gem list sqlite3

  • LOCAL GEMS ***
    sqlite3 (1.3.3)
    sqlite3-ruby (1.3.3, 1.3.2, 1.2.5)

database.yml
production:
adapter: sqlite3
database: db/prod.db

development:
adapter: sqlite3
database: db/dev.db

test:
adapter: sqlite3
database: db/test.db

Error during migration:

$ RAILS_ENV=production rake db:migrate
(in /c/www/redmine-1.1.2)
Setup: migrating ========================================================
<snip>
CreateJournals: migrating ===============================================
-- create_table(:journals, {:force=>true})
> 0.0090s
-
create_table(:journal_details, {:force=>true})
> 0.0050s
-
add_index("journals", ["journalized_id", "journalized_type"], {:name=>"journals_journalized_id"})
> 0.0010s
-
add_index("journal_details", ["journal_id"], {:name=>"journal_details_journal_id"})
> 0.0020s
-
drop_table(:issue_histories)
rake aborted!
An error has occurred, this and all later migrations canceled:

SQLite3::CantOpenException: unable to open database file: DROP TABLE "issue_histories"

ssssss

Actions #5

Updated by Jon Lambert about 14 years ago

Interesting post above. Do you have problems with bots using redmine? ;-)

Anyway I've hopefully verified that the problem is not with my ruby or sqlite3-ruby installation with the following test:

$ cat testsql.rb 
require 'rubygems'
require 'sqlite3'
require 'pp'

db = SQLite3::Database.new( "test.db" )

db.execute("create table t1(a, b, c)")
sql = <<SQL
    insert into t1 values ( 'one', 'two', 'foo' );
    insert into t1 values ( 'three', 'four', 'bar' );
    insert into t1 values ( 'five', 'six', 'baz' );
SQL
db.execute_batch( sql )
rows = db.execute( "select * from t1" )
pp rows

db.execute("create table t2(a, b)")
db.execute("insert into t2 select a,b from t1")
db.execute("drop table t1")
rows = db.execute2( "select * from t2" )
pp rows

$ ruby testsql.rb 
[["one", "two", "foo"], ["three", "four", "bar"], ["five", "six", "baz"]]
[["a", "b"], ["one", "two"], ["three", "four"], ["five", "six"]]

That ought to narrow the problem down to either ActiveRecord or Redmine, no?

Actions #6

Updated by Etienne Massip about 14 years ago

  • Status changed from New to Closed
  • Resolution set to Duplicate

Closed as duplicated by #8182.

Actions

Also available in: Atom PDF