@@ -19,6 +19,9 @@ if not M then
19
19
-- and be not nullable. Values in this part are considered as bucket
20
20
-- identifiers.
21
21
shard_index = nil ,
22
+ -- How to manage the schema. Auto - do everything automatically,
23
+ -- manual - expect some things to be done externally outside of vshard.
24
+ management_mode = ' auto' ,
22
25
errinj = {
23
26
ERRINJ_UPGRADE = false ,
24
27
},
78
81
--
79
82
local function schema_init_0_1_15_0 (username , password )
80
83
llog .info (" Initializing schema %s" , schema_version_make ({0 , 1 , 15 , 0 }))
81
- box .schema .user .create (username , {
82
- password = password ,
83
- if_not_exists = true ,
84
- })
85
- box .schema .user .grant (username , ' replication' , nil , nil ,
86
- {if_not_exists = true })
87
84
88
85
local bucket = box .schema .space .create (' _bucket' )
89
86
bucket :format ({
@@ -94,11 +91,19 @@ local function schema_init_0_1_15_0(username, password)
94
91
bucket :create_index (' pk' , {parts = {' id' }})
95
92
bucket :create_index (' status' , {parts = {' status' }, unique = false })
96
93
97
- local exports = lvexports .log [1 ]
98
- assert (exports .version == ' 0.1.15.0' )
99
- exports = lvexports .compile (exports )
100
- lvexports .deploy_funcs (exports )
101
- lvexports .deploy_privs (exports , username )
94
+ if M .management_mode == ' auto' then
95
+ box .schema .user .create (username , {
96
+ password = password ,
97
+ if_not_exists = true ,
98
+ })
99
+ box .schema .user .grant (username , ' replication' , nil , nil ,
100
+ {if_not_exists = true })
101
+ local exports = lvexports .log [1 ]
102
+ assert (exports .version == ' 0.1.15.0' )
103
+ exports = lvexports .compile (exports )
104
+ lvexports .deploy_funcs (exports )
105
+ lvexports .deploy_privs (exports , username )
106
+ end
102
107
box .space ._schema :replace ({' vshard_version' , 0 , 1 , 15 , 0 })
103
108
end
104
109
130
135
-- to a certain vshard version.
131
136
--
132
137
local function schema_upgrade_core_features ()
133
- if M .is_core_up_to_date then
138
+ if M .is_core_up_to_date or M . management_mode ~= ' auto ' then
134
139
return
135
140
end
136
141
local version = schema_current_version ()
@@ -186,8 +191,10 @@ local function schema_upgrade(target_version, username, password)
186
191
next_version )
187
192
exports = lvexports .compile (exports )
188
193
handler .upgrade ()
189
- lvexports .deploy_funcs (exports )
190
- lvexports .deploy_privs (exports , username )
194
+ if M .management_mode == ' auto' then
195
+ lvexports .deploy_funcs (exports )
196
+ lvexports .deploy_privs (exports , username )
197
+ end
191
198
end )
192
199
if ok and errinj == ' end' then
193
200
ok , err1 = false , ' Errinj in end'
@@ -204,8 +211,10 @@ local function schema_upgrade(target_version, username, password)
204
211
prev_version )
205
212
exports = lvexports .compile (exports )
206
213
handler .downgrade ()
207
- lvexports .deploy_funcs (exports )
208
- lvexports .deploy_privs (exports , username )
214
+ if M .management_mode == ' auto' then
215
+ lvexports .deploy_funcs (exports )
216
+ lvexports .deploy_privs (exports , username )
217
+ end
209
218
end )
210
219
if not ok then
211
220
llog .info (" Couldn't downgrade schema to %s - fatal error: " ..
259
268
260
269
local function schema_cfg (cfg )
261
270
M .shard_index = cfg .shard_index
271
+ M .management_mode = cfg .schema_management_mode
262
272
end
263
273
264
274
M .current_version = schema_current_version
0 commit comments