mirror of
https://github.com/redmine/redmine.git
synced 2025-12-16 13:30:28 +01:00
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
This commit is contained in:
@@ -47,6 +47,9 @@ module RedmineApp
|
|||||||
# Do not include all helpers
|
# Do not include all helpers
|
||||||
config.action_controller.include_all_helpers = false
|
config.action_controller.include_all_helpers = false
|
||||||
|
|
||||||
|
# Since Redmine 4.0, boolean values are stored in sqlite3 databases as 1 and 0
|
||||||
|
config.active_record.sqlite3.represent_boolean_as_integer = true
|
||||||
|
|
||||||
# Sets the Content-Length header on responses with fixed-length bodies
|
# Sets the Content-Length header on responses with fixed-length bodies
|
||||||
config.middleware.insert_after Rack::Sendfile, Rack::ContentLength
|
config.middleware.insert_after Rack::Sendfile, Rack::ContentLength
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
Reference in New Issue
Block a user