tarantool / ddl

The DDL module enables you to describe data schema in a declarative YAML-based format.
BSD 2-Clause "Simplified" License
12 stars 6 forks source link

Migration script with ddl.set_schema() fails if it has index definition with exclude_null #110

Closed dkasimovskiy closed 1 year ago

dkasimovskiy commented 1 year ago

Migration script with ddl.set_schema() fails if it has index definition with exclude_null option in index parts. There are to different error depending on presence is_nullable = false, option in definition.

Migration script:

return {
    up = function()

        local ddl = require('ddl')
        local schema = {
            spaces = {
                message = {
                    engine = 'memtx',
                    is_local = false,
                    temporary = false,
                    format = {
                        { name = 'id', type = 'integer', is_nullable = false },
                        { name = 'bucket_id', type = 'unsigned', is_nullable = false },
                        { name = 'user_key', type = 'string', is_nullable = false },
                        { name = 'package_id', type = 'integer', is_nullable = true }
                    },
                    indexes = {
                        {
                            name = 'primary',
                            type = 'TREE',
                            unique = true,
                            parts = {
                                {
                                    path = 'id',
                                    is_nullable = false,
                                    type = 'integer'
                                }
                            }
                        },
                        {
                            name = 'bucket_id',
                            type = 'TREE',
                            unique = false,
                            parts = {
                                {
                                    path = 'bucket_id',
                                    is_nullable = false,
                                    type = 'unsigned'
                                }
                            }
                        },
                        {
                            name = 'package_id_idx',
                            type = 'TREE',
                            unique = false,
                            parts = {
                                {
                                    path = 'package_id',
                                    exclude_null = true,
                                    type = 'integer'
                                }
                            }
                        }
                    },
                    sharding_key = { 'id' }
                }
            }
        }

        ddl.set_schema(schema)

        return ddl.check_schema(schema)
    end
}