Open AnaNek opened 1 year ago
The ddl module is responsible for applying the schema on the cluster. This module does not allow to modify the schema after applying it.
ddl
In Tarantool, there are two types of schema migration that do not require data migration:
To make it easier to write migrations, we should add the ability to expand the schema by adding nullable field to the end of the space.
Example of migrations:
Migration 1:
return { up = function() local ddl = require('ddl') local schema = { spaces = { keyval = { engine = 'memtx', is_local = false, temporary = false, format = { { name = 'bucket_id', type = 'unsigned', is_nullable = false }, { name = 'key', type = 'string', is_nullable = false }, { name = 'value', type = 'string', is_nullable = false } }, indexes = {{ name = 'pk', type = 'TREE', unique = true, parts = { { path = 'key', type = 'string', is_nullable = false } } }, { name = 'bucket_id', type = 'TREE', unique = false, parts = { { path = 'bucket_id', type = 'unsigned', is_nullable = false } } }}, sharding_key = { 'key' } } } } assert(ddl.check_schema(schema)) ddl.set_schema(schema) end }
Migration 2:
return { up = function() local ddl = require('ddl') local schema = { spaces = { keyval = { engine = 'memtx', is_local = false, temporary = false, format = { { name = 'bucket_id', type = 'unsigned', is_nullable = false }, { name = 'key', type = 'string', is_nullable = false }, { name = 'value', type = 'string', is_nullable = false }, { name = 'state', type = 'map', is_nullable = true } }, indexes = {{ name = 'pk', type = 'TREE', unique = true, parts = { { path = 'key', type = 'string', is_nullable = false } } }, { name = 'bucket_id', type = 'TREE', unique = false, parts = { { path = 'bucket_id', type = 'unsigned', is_nullable = false } } }}, sharding_key = { 'key' } } } } assert(ddl.check_schema(schema)) ddl.set_schema(schema) end }
The
ddl
module is responsible for applying the schema on the cluster. This module does not allow to modify the schema after applying it.In Tarantool, there are two types of schema migration that do not require data migration:
To make it easier to write migrations, we should add the ability to expand the schema by adding nullable field to the end of the space.
Example of migrations:
Migration 1:
Migration 2: