[Bug] Clears spaces except the first one in the scheme when I call the package.reload() or when I call again $ make run
nodermann opened this issue · comments
Related issue: moonlibs/tarantoolapp#15
automigrate = true
local spacer = require 'spacer'.get()
spacer:space({
name = 'object3',
format = {
{ name = 'id', type = 'unsigned' },
},
indexes = {
{ name = 'primary', type = 'tree', unique = true, parts = { 'id' } }
}
})
spacer:space({
name = 'object1',
format = {
{ name = 'id', type = 'unsigned' },
},
indexes = {
{ name = 'primary', type = 'tree', unique = true, parts = { 'id' } }
}
})
spacer:space({
name = 'object2',
format = {
{ name = 'id', type = 'unsigned' },
},
indexes = {
{ name = 'primary', type = 'tree', unique = true, parts = { 'id' } }
}
})
tarantool> box.space
---
- object2:
is_local: false
temporary: false
engine: memtx
object3:
is_local: false
temporary: false
engine: memtx
object1:
is_local: false
temporary: false
engine: memtx
...
tarantool> box.space.object1:select()
---
- []
...
tarantool> box.space.object2:select()
---
- []
...
tarantool> box.space.object3:select()
---
- []
...
tarantool> box.space.object1:insert({1})
---
- [1]
...
tarantool> box.space.object2:insert({2})
---
- [2]
...
tarantool> box.space.object3:insert({3})
---
- [3]
...
tarantool> box.space.object1:select()
---
- - [1]
...
tarantool> box.space.object2:select()
---
- - [2]
...
tarantool> box.space.object3:select()
---
- - [3]
...
tarantool> package.reload()
2020-06-18 12:29:25.526 [50034] main/102/ttt I> 2nd load. Unloading {spacer, schema, app, spacer.version, spacer.transformations, spacer.migration, spacer.util, spacer.stmt, spacer.ops, spacer.inspect, config, inspect, spacer.compat, mod1, spacer.fileio}
2020-06-18 12:29:25.526 [50034] main/102/ttt I> package.reload:cleanup...
2020-06-18 12:29:25.529 [50034] main/102/ttt I> app "ttt" destroy
2020-06-18 12:29:25.529 [50034] main/102/ttt I> package.reload:cleanup finished
config table: 0x010522e6b0 loading config ./conf.lua
2020-06-18 12:29:25.535 [50034] main/102/ttt I> app "ttt" init
2020-06-18 12:29:25.550 [50034] main/117/lua reload.lua:160 E> Cleanup 1, running
---
...
tarantool> box.space.object3:select()
---
- - [3]
...
tarantool> box.space.object2:select()
---
- []
...
tarantool> box.space.object1:select()
---
- []
...
As a quick fix add this option to spacer config - keep_obsolete_spaces = true
. But keep in mind that you shouldn't use automigrate when preparing for a production use.
I'll think on a better solution later.
Hi! I ditched automigrate option from the spacer and replaced with an :automigrate() method which should be called after all spacer:space() calls (check the readme for details).