mirror of
https://github.com/redmine/redmine.git
synced 2025-11-06 05:16:12 +01:00
Sqlite3: change default value for booleans to 1 or 0 (#23630).
git-svn-id: http://svn.redmine.org/redmine/trunk@17501 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
93
db/migrate/20180923091603_change_sqlite_booleans_default.rb
Normal file
93
db/migrate/20180923091603_change_sqlite_booleans_default.rb
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
class ChangeSqliteBooleansDefault < ActiveRecord::Migration[5.2]
|
||||||
|
DEFAULTS = {
|
||||||
|
"auth_sources" => {
|
||||||
|
"onthefly_register" => false,
|
||||||
|
"tls" => false
|
||||||
|
},
|
||||||
|
"custom_field_enumerations" => {
|
||||||
|
"active" => true
|
||||||
|
},
|
||||||
|
"custom_fields" => {
|
||||||
|
"is_required" => false,
|
||||||
|
"is_for_all" => false,
|
||||||
|
"is_filter" => false,
|
||||||
|
"searchable" => false,
|
||||||
|
"editable" => true,
|
||||||
|
"visible" => true,
|
||||||
|
"multiple" => false
|
||||||
|
},
|
||||||
|
"email_addresses" => {
|
||||||
|
"is_default" => false,
|
||||||
|
"notify" => true
|
||||||
|
},
|
||||||
|
"enumerations" => {
|
||||||
|
"is_default" => false,
|
||||||
|
"active" => true
|
||||||
|
},
|
||||||
|
"imports" => {
|
||||||
|
"finished" => false
|
||||||
|
},
|
||||||
|
"issue_statuses" => {
|
||||||
|
"is_closed" => false
|
||||||
|
},
|
||||||
|
"issues" => {
|
||||||
|
"is_private" => false
|
||||||
|
},
|
||||||
|
"journals" => {
|
||||||
|
"private_notes" => false
|
||||||
|
},
|
||||||
|
"members" => {
|
||||||
|
"mail_notification" => false
|
||||||
|
},
|
||||||
|
"messages" => {
|
||||||
|
"locked" => false
|
||||||
|
},
|
||||||
|
"projects" => {
|
||||||
|
"is_public" => true,
|
||||||
|
"inherit_members" => false
|
||||||
|
},
|
||||||
|
"repositories" => {
|
||||||
|
"is_default" => false
|
||||||
|
},
|
||||||
|
"roles" => {
|
||||||
|
"assignable" => true,
|
||||||
|
"all_roles_managed" => true
|
||||||
|
},
|
||||||
|
"trackers" => {
|
||||||
|
"is_in_chlog" => false,
|
||||||
|
"is_in_roadmap" => true
|
||||||
|
},
|
||||||
|
"user_preferences" => {
|
||||||
|
"hide_mail" => true
|
||||||
|
},
|
||||||
|
"users" => {
|
||||||
|
"admin" => false,
|
||||||
|
"must_change_passwd" => false
|
||||||
|
},
|
||||||
|
"wiki_pages" => {
|
||||||
|
"protected" => false
|
||||||
|
},
|
||||||
|
"workflows" => {
|
||||||
|
"assignee" => false,
|
||||||
|
"author" => false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def up
|
||||||
|
if ActiveRecord::Base.connection.adapter_name =~ /sqlite/i
|
||||||
|
DEFAULTS.each do |table, defaults|
|
||||||
|
defaults.each do |column, value|
|
||||||
|
# Reset default values for boolean column (t/f => 1/0)
|
||||||
|
change_column_default(table, column, value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
if ActiveRecord::Base.connection.adapter_name =~ /sqlite/i
|
||||||
|
# Cannot restore default values as t/f
|
||||||
|
raise ActiveRecord::IrreversibleMigration
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user