<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2016-2022 ActionTech.
  ~ License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
  -->

<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
           xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="schema">
        <xs:complexType>
            <xs:sequence minOccurs="0">
                <xs:choice maxOccurs="unbounded">
                    <xs:element maxOccurs="unbounded" name="shardingTable">
                        <xs:complexType>
                            <xs:sequence minOccurs="0">
                                <xs:element maxOccurs="unbounded" name="childTable">
                                    <xs:complexType>
                                        <xs:sequence minOccurs="0">
                                            <xs:element maxOccurs="unbounded" name="childTable">
                                                <xs:complexType>
                                                    <xs:attribute name="name" type="xs:string" use="required"/>
                                                    <xs:attribute name="joinColumn" type="xs:string" use="required"/>
                                                    <xs:attribute name="parentColumn" type="xs:string" use="required"/>
                                                    <xs:attribute name="incrementColumn" type="xs:string"/>
                                                    <xs:attribute name="sqlMaxLimit" type="xs:integer"/>
                                                    <xs:attribute name="specifyCharset" type="xs:boolean"/>
                                                </xs:complexType>
                                            </xs:element>
                                        </xs:sequence>
                                        <xs:attribute name="name" type="xs:string" use="required"/>
                                        <xs:attribute name="joinColumn" type="xs:string" use="required"/>
                                        <xs:attribute name="parentColumn" type="xs:string" use="required"/>
                                        <xs:attribute name="incrementColumn" type="xs:string"/>
                                        <xs:attribute name="sqlMaxLimit" type="xs:integer"/>
                                    </xs:complexType>
                                </xs:element>
                            </xs:sequence>
                            <xs:attribute name="name" type="xs:string" use="required"/>
                            <xs:attribute name="shardingNode" type="xs:string" use="required"/>
                            <xs:attribute name="shardingColumn" type="xs:string" use="required"/>
                            <xs:attribute name="function" type="xs:string" use="required"/>
                            <xs:attribute name="sqlRequiredSharding" type="xs:boolean"/>
                            <xs:attribute name="incrementColumn" type="xs:string"/>
                            <xs:attribute name="sqlMaxLimit" type="xs:integer"/>
                            <xs:attribute name="specifyCharset" type="xs:boolean"/>
                        </xs:complexType>
                    </xs:element>
                    <xs:element maxOccurs="unbounded" name="globalTable">
                        <xs:complexType>
                            <xs:attribute name="name" type="xs:string" use="required"/>
                            <xs:attribute name="shardingNode" type="xs:string" use="required"/>
                            <xs:attribute name="sqlMaxLimit" type="xs:integer"/>
                            <xs:attribute name="cron" type="xs:string"/>
                            <xs:attribute name="checkClass" type="xs:string"/>
                            <xs:attribute name="specifyCharset" type="xs:boolean"/>
                        </xs:complexType>
                    </xs:element>
                    <xs:element maxOccurs="unbounded" name="singleTable">
                        <xs:complexType>
                            <xs:attribute name="name" type="xs:string" use="required"/>
                            <xs:attribute name="shardingNode" type="xs:string" use="required"/>
                            <xs:attribute name="sqlMaxLimit" type="xs:integer"/>
                            <xs:attribute name="specifyCharset" type="xs:boolean"/>
                        </xs:complexType>
                    </xs:element>
                </xs:choice>
            </xs:sequence>
            <xs:attribute name="name" type="xs:string" use="required"/>
            <xs:attribute name="sqlMaxLimit" type="xs:integer"/>
            <xs:attribute name="shardingNode" type="xs:string"/>
            <xs:attribute name="function" type="xs:string"/>
            <xs:attribute name="logicalCreateADrop" type="xs:boolean"/>
        </xs:complexType>
    </xs:element>
    <xs:element name="shardingNode">
        <xs:complexType>
            <xs:attribute name="name" type="xs:string" use="required"/>
            <xs:attribute name="dbGroup" type="xs:string" use="required"/>
            <xs:attribute name="database" type="xs:string" use="required"/>
        </xs:complexType>
    </xs:element>
    <xs:element name="function">
        <xs:complexType>
            <xs:sequence minOccurs="0" maxOccurs="unbounded">
                <xs:element name="property">
                    <xs:complexType>
                        <xs:simpleContent>
                            <xs:extension base="xs:string">
                                <xs:attribute name="name" type="xs:string" use="required"/>
                            </xs:extension>
                        </xs:simpleContent>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
            <xs:attribute name="name" type="xs:string" use="required"/>
            <xs:attribute name="class" type="xs:string" use="required"/>
        </xs:complexType>
    </xs:element>
</xs:schema>