#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

spring.shardingsphere.datasource.names=ds-0,ds-1

spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://localhost:3306/sys?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver
spring.shardingsphere.datasource.ds-0.username=root
spring.shardingsphere.datasource.ds-0.password=apijson

spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3306/sys?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.jdbc.Driver
spring.shardingsphere.datasource.ds-1.username=root
spring.shardingsphere.datasource.ds-1.password=apijson

spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=id
spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=database-inline
spring.shardingsphere.rules.sharding.binding-tables[0]=Moment,Comment
spring.shardingsphere.rules.sharding.broadcast-tables=apijson_user

spring.shardingsphere.rules.sharding.tables.Moment.actual-data-nodes=ds-$->{0..1}.Moment

spring.shardingsphere.rules.sharding.tables.Moment.key-generate-strategy.column=id
spring.shardingsphere.rules.sharding.tables.Moment.key-generate-strategy.key-generator-name=snowflake

spring.shardingsphere.rules.sharding.tables.Comment.actual-data-nodes=ds-$->{0..1}.Comment

spring.shardingsphere.rules.sharding.tables.Comment.key-generate-strategy.column=id
spring.shardingsphere.rules.sharding.tables.Comment.key-generate-strategy.key-generator-name=snowflake

spring.shardingsphere.rules.sharding.tables.apijson_user.actual-data-nodes=ds-$->{0..1}.apijson_user

spring.shardingsphere.rules.sharding.tables.apijson_user.key-generate-strategy.column=id
spring.shardingsphere.rules.sharding.tables.apijson_user.key-generate-strategy.key-generator-name=snowflake

spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.type=INLINE
spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.props.algorithm-expression=ds-$->{userId % 2}

spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
