|
| 1 | +local helper = require('test.helper') |
| 2 | + |
| 3 | +return { |
| 4 | + init = helper.wrap_schema_init(function() |
| 5 | + local engine = os.getenv('ENGINE') or 'memtx' |
| 6 | + local customers_space = box.schema.space.create('customers', { |
| 7 | + format = { |
| 8 | + {name = 'id', type = 'unsigned'}, |
| 9 | + {name = 'bucket_id', type = 'unsigned'}, |
| 10 | + {name = 'name', type = 'string'}, |
| 11 | + {name = 'age', type = 'number'}, |
| 12 | + }, |
| 13 | + if_not_exists = true, |
| 14 | + engine = engine, |
| 15 | + }) |
| 16 | + customers_space:create_index('bucket_id', { |
| 17 | + parts = { {field = 'bucket_id'}, {field = 'id'} }, |
| 18 | + if_not_exists = true, |
| 19 | + }) |
| 20 | + |
| 21 | + -- https://github.com/tarantool/migrations/blob/a7c31a17f6ac02d4498b4203c23e495856861444/migrator/utils.lua#L35-L53 |
| 22 | + if box.space._ddl_sharding_key == nil then |
| 23 | + local sharding_space = box.schema.space.create('_ddl_sharding_key', { |
| 24 | + format = { |
| 25 | + {name = 'space_name', type = 'string', is_nullable = false}, |
| 26 | + {name = 'sharding_key', type = 'array', is_nullable = false} |
| 27 | + }, |
| 28 | + if_not_exists = true, |
| 29 | + }) |
| 30 | + sharding_space:create_index( |
| 31 | + 'space_name', { |
| 32 | + type = 'TREE', |
| 33 | + unique = true, |
| 34 | + parts = {{'space_name', 'string', is_nullable = false}}, |
| 35 | + if_not_exists = true, |
| 36 | + } |
| 37 | + ) |
| 38 | + end |
| 39 | + box.space._ddl_sharding_key:replace{'customers', {'id'}} |
| 40 | + end), |
| 41 | + wait_until_ready = helper.wait_schema_init, |
| 42 | +} |
0 commit comments