diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2018-09-23 08:48:29 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2018-09-23 08:48:29 +0000 |
commit | 5ae629b3bbcf4bbbe0018f31f499f1ffb49dc7ad (patch) | |
tree | 8171276502481d82580c045c72fe769fa0faeba9 /db/migrate | |
parent | e856c9f879f15f31317ddfcf35042e799b90f783 (diff) | |
download | redmine-5ae629b3bbcf4bbbe0018f31f499f1ffb49dc7ad.tar.gz redmine-5ae629b3bbcf4bbbe0018f31f499f1ffb49dc7ad.zip |
Sqlite3: Boolean values are now stored as 1 and 0 (#23630).
git-svn-id: http://svn.redmine.org/redmine/trunk@17500 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'db/migrate')
-rw-r--r-- | db/migrate/20180923082945_change_sqlite_booleans_to_0_and_1.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/db/migrate/20180923082945_change_sqlite_booleans_to_0_and_1.rb b/db/migrate/20180923082945_change_sqlite_booleans_to_0_and_1.rb new file mode 100644 index 000000000..fb789ae10 --- /dev/null +++ b/db/migrate/20180923082945_change_sqlite_booleans_to_0_and_1.rb @@ -0,0 +1,46 @@ +class ChangeSqliteBooleansTo0And1 < ActiveRecord::Migration[5.2] + + COLUMNS = { + AuthSource => ['onthefly_register', 'tls'], + CustomFieldEnumeration => ['active'], + CustomField => ['is_required', 'is_for_all', 'is_filter', 'searchable', 'editable', 'visible', 'multiple'], + EmailAddress => ['is_default', 'notify'], + Enumeration => ['is_default', 'active'], + Import => ['finished'], + IssueStatus => ['is_closed'], + Issue => ['is_private'], + Journal => ['private_notes'], + Member => ['mail_notification'], + Message => ['locked'], + Project => ['is_public', 'inherit_members'], + Repository => ['is_default'], + Role => ['assignable', 'all_roles_managed'], + Tracker => ['is_in_chlog', 'is_in_roadmap'], + UserPreference => ['hide_mail'], + User => ['admin', 'must_change_passwd'], + WikiPage => ['protected'], + WorkflowRule => ['assignee', 'author'], + } + + def up + if ActiveRecord::Base.connection.adapter_name =~ /sqlite/i + COLUMNS.each do |klass, columns| + columns.each do |column| + klass.where("#{column} = 't'").update_all(column => 1) + klass.where("#{column} = 'f'").update_all(column => 0) + end + end + end + end + + def down + if ActiveRecord::Base.connection.adapter_name =~ /sqlite/i + COLUMNS.each do |klass, columns| + columns.each do |column| + klass.where("#{column} = 1").update_all(column => 't') + klass.where("#{column} = 0").update_all(column => 'f') + end + end + end + end +end |