1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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
|