Skip to content
This repository was archived by the owner on Apr 13, 2021. It is now read-only.

Commit ef9c4e4

Browse files
authored
Merge pull request #77 from annikoff/fix
Fix migration
2 parents 5d50001 + a577e3c commit ef9c4e4

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## [1.0.1](https://github.com/annikoff/redmine_plugin_computed_custom_field/releases/tag/v1.0.0) - 2017-02-20
4+
### Fixed
5+
- Migration.
6+
37
## [1.0.0](https://github.com/annikoff/redmine_plugin_computed_custom_field/releases/tag/v1.0.0) - 2017-02-15
48
### Added
59
- New formula constructions `cfs[cf_id]`. Thanks to [ecanuto](https://github.com/ecanuto) for the idea.

db/migrate/20170205204731_convert_custom_fields.rb

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class ConvertCustomFields < ActiveRecord::Migration
2+
def up
3+
fields = CustomField.where(field_format: 'computed')
4+
fields.each do |field|
5+
format = case field.format_store[:output_format]
6+
when 'integer'
7+
'int'
8+
when 'percentage'
9+
'float'
10+
else
11+
field.format_store[:output_format]
12+
end
13+
formula = field.format_store[:formula]
14+
sql = "UPDATE #{CustomField.table_name} SET "
15+
sql << "is_computed = '1', field_format = '#{format}', formula = '#{formula}' WHERE id = #{field.id}"
16+
ActiveRecord::Base.connection.execute(sql)
17+
end
18+
end
19+
end

init.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
author 'Yakov Annikov'
44
url 'https://github.com/annikoff/redmine_plugin_computed_custom_field'
55
description ''
6-
version '1.0.0'
6+
version '1.0.1'
77
settings default: {}
88
end
99

0 commit comments

Comments
 (0)