プロジェクト

全般

プロフィール

Vote #67505

完了

Problem when importing git repository

Admin Redmine さんがほぼ2年前に追加. ほぼ2年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Database_21
対象バージョン:
開始日:
2010/06/28
期日:
進捗率:

100%

予定工数:
category_id:
21
version_id:
21
issue_org_id:
5771
author_id:
17191
assigned_to_id:
5
comments:
16
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

When importing git repository I got following error:

ActiveRecord::StatementInvalid (PGError: ERROR:  value too long for type character varying(255)
: INSERT INTO "changes" ("changeset_id", "action", "branch", "path", "revision", "from_path", "from_revision") VALUES(885, E'D', NULL, E'"src/main/resources/...lot of text..."', NULL, NULL, N
ULL) RETURNING "id")
  lib/redmine/scm/adapters/abstract_adapter.rb:300:in `save'
  lib/redmine/scm/adapters/abstract_adapter.rb:299:in `each'
  lib/redmine/scm/adapters/abstract_adapter.rb:299:in `save'
  lib/redmine/scm/adapters/abstract_adapter.rb:289:in `save'
  app/models/repository/git.rb:65:in `fetch_changesets'
  app/models/repository/git.rb:65:in `each'
  app/models/repository/git.rb:65:in `fetch_changesets'
  app/controllers/repositories_controller.rb:70:in `show'

Change in abstract_adapter.rb that fix it:

Change.create(:changeset => changeset,
              :action => file[:action],
              :path => file[:path][0...255])

journals

First one for you Holger ;-) Though I suspect this isn't a pg-only thing.

Thanks for the report Pavel!
--------------------------------------------------------------------------------
I looks like the current schema allows only path names (inside a repository) with a maximum length of 255 chars all combined.

The column type in the migration is @:string@, which translates to a varchar(255) in most databases. So we either live with this or change the column type to @:text@ which would allow arbitrary length paths (which I would prefer).
--------------------------------------------------------------------------------
On Sqlite3, this is not reproducible as it happilly stuffs over 1000 chars long strings into a @varchar(255)@... Now setting up a local PostgreSQL DB for testing...

@Pavel: Which version of PostgreSQL are you using?
--------------------------------------------------------------------------------
8.4.2
--------------------------------------------------------------------------------
I could reproduce the error on Postgres 8.4. The attached patch fixes this behavior by changing the datatype of @:path@ and @:from_path@ from text (aka. @varchar(255)@) to @text@. Also included into the patch is an update of the test git repository with a new commit for a really long file.

Eric, please check the patch and commit at will.
--------------------------------------------------------------------------------
Committed in r3828.
--------------------------------------------------------------------------------
Someone reported a bug with this on MySQL

http://twitter.com/chrismckee/status/17862499316
--------------------------------------------------------------------------------
Problem is occurring in \apps\redmine\db\migrate\20100705164950_change_changes_path_length_limit.rb
Output on migrate as follows:

<pre>
C:\BitNami-RedmineStack\apps\redmine>rake db:migrate RAILS_ENV="production" --tr
ace > log.txt
rake aborted!
An error has occurred, all later migrations canceled:

Mysql::Error: BLOB/TEXT column 'path' can't have a default value: ALTER TABLE `c
hanges` CHANGE `path` `path` text DEFAULT '' NOT NULL
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/activ
e_record/connection_adapters/abstract_adapter.rb:219:in `log'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/activ
e_record/connection_adapters/mysql_adapter.rb:323:in `execute'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/activ
e_record/connection_adapters/mysql_adapter.rb:511:in `change_column'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/activ
e_record/migration.rb:352:in `send'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/activ
e_record/migration.rb:352:in `method_missing'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/activ
e_record/migration.rb:328:in `say_with_time'
C:/BitNami-RedmineStack/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/activ
e_record/migration.rb:328:in `say_with_time'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/activ
e_record/migration.rb:348:in `method_missing'
./db/migrate//20100705164950_change_changes_path_length_limit.rb:3:in `up_withou
t_benchmarks'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/activ
e_record/migration.rb:282:in `send'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/activ
e_record/migration.rb:282:in `migrate'
C:/BitNami-RedmineStack/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/activ
e_record/migration.rb:282:in `migrate'
C:1:in `__send__'
C:1:in `migrate'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/activ
e_record/migration.rb:486:in `migrate'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/activ
e_record/migration.rb:562:in `call'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/activ
e_record/migration.rb:562:in `ddl_transaction'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/activ
e_record/migration.rb:485:in `migrate'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/activ
e_record/migration.rb:472:in `each'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/activ
e_record/migration.rb:472:in `migrate'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/activ
e_record/migration.rb:400:in `up'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/activ
e_record/migration.rb:383:in `migrate'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/tasks/databa
ses.rake:116
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:i
n `call'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:i
n `execute'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:i
n `each'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:i
n `execute'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:i
n `invoke_with_call_chain'
C:/BitNami-RedmineStack/ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:i
n `invoke_with_call_chain'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:i
n `invoke'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:
in `invoke_task'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:
in `top_level'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:
in `each'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:
in `top_level'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:
in `standard_exception_handling'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:
in `top_level'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:
in `run'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:
in `standard_exception_handling'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:
in `run'
C:/BitNami-RedmineStack/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
C:/BitNami-RedmineStack/ruby/bin/rake:19:in `load'
C:/BitNami-RedmineStack/ruby/bin/rake:19
</pre>

Removing this file allows trunk to migrate successfully.

--------------------------------------------------------------------------------
Forgot to add; running on Windows Bitnami Redmine stack (Redmine trunk) and MySQL5
--------------------------------------------------------------------------------
It seems @TEXT@ columns can't have a default either: "_BLOB and TEXT columns cannot have DEFAULT values_":http://dev.mysql.com/doc/refman/5.0/en/blob.html, though there's no mention of the @NOT NULL@ thing (which might be an incidence of the no default, I'm no db expert in any way).
--------------------------------------------------------------------------------
I created an amendment patch to the first one. It removes the default value from the column and instead sets it in a @before_save@ hook in the model. This should fix the issue.

It is also available on "Github":http://github.com/meineerde/redmine/commit/89cb1b9c8b6e8f9e499e350b067115a50b63c75b.
--------------------------------------------------------------------------------
I've changed the migration in r3830. It's odd because both my desktop and CI server showed that migration working with MySQL, SQLite, and Postgres.
--------------------------------------------------------------------------------
I updated Redmine to r3859 and got error when migrate:
<pre>
(in C:/redmine trunk)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
== ChangeChangesPathLengthLimit: migrating ===================================
-- change_column(:changes, :path, :text, {:null=>false})
rake aborted!
An error has occurred, all later migrations canceled:

Mysql::Error: BLOB/TEXT column 'path' can't have a default value: ALTER TABLE `c
hanges` CHANGE `path` `path` text DEFAULT '' NOT NULL
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_a
dapters/abstract_adapter.rb:219:in `log'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_a
dapters/mysql_adapter.rb:323:in `execute'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_a
dapters/mysql_adapter.rb:511:in `change_column'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb
:352:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb
:352:in `method_missing'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb
:328:in `say_with_time'
c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb
:328:in `say_with_time'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb
:348:in `method_missing'
./db/migrate//20100705164950_change_changes_path_length_limit.rb:3:in `up_withou
t_benchmarks'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb
:282:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb
:282:in `migrate'
c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb
:282:in `migrate'
c:1:in `__send__'
c:1:in `migrate'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb
:486:in `migrate'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb
:562:in `call'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb
:562:in `ddl_transaction'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb
:485:in `migrate'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb
:472:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb
:472:in `migrate'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb
:400:in `up'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb
:383:in `migrate'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/tasks/databases.rake:116
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_c
hain'
c:/ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_c
hain'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exceptio
n_handling'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exceptio
n_handling'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
c:/ruby/bin/rake:19:in `load'
c:/ruby/bin/rake:19
</pre>
--------------------------------------------------------------------------------
Kirill Ponomarev wrote:
> I updated Redmine to r3859 and got error when migrate:

You probably are on MySQL on a 32bit windows? We are already aware of this, a fix should get pushed soon (you can get the fix "here":/boards/2/topics/15654?r=15824#message-15824 if you are in a hurry).
--------------------------------------------------------------------------------
Updated the migration in r3860 and r3861.
--------------------------------------------------------------------------------
For the record, this is not a problem on Windows only. MariaDB 5.1 (and thus MySQL 5.1 and newer) on Linux have the same issue.

A quick fix if you're running 1.0.0 from git is:

git cherry-pick a628b0f186cf4d182ce5cee1a497ad42c5246406
--------------------------------------------------------------------------------


related_issues

relates,Closed,5846,ChangeChangesPathLengthLimit does not remove default for MySQL

Admin Redmine さんがほぼ2年前に更新

  • カテゴリDatabase_21 にセット
  • 対象バージョン1.0.1_21 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0