vivek579 opened a new issue #16277:
URL: https://github.com/apache/shardingsphere/issues/16277


   ## Question
   
   **For English only**, other languages will not accept.
   
   Before asking a question, make sure you have:
   
   - Googled your question.
   - Searched open and closed [GitHub 
issues](https://github.com/apache/shardingsphere/issues).
   - Read documentation: [ShardingSphere 
Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   Please pay attention on issues you submitted, because we maybe need more 
details. 
   If no response anymore and we cannot reproduce it on current information, we 
will **close it**.
   
   
   I am trying to execute DDL statement (ALTER query) in sharded table with 
flyway, but in logs i see **ShardingRuleConfiguration** is getting loaded after 
Flyway applies all the migrations, Hence DDL query is not getting applied to 
sharded tables.
   
   How can we load defined sharding rules in spring boot before Flyway start 
running migration ?
   
   **application.yml:** [Flyway and sharing rule configurations]
   
   spring:
     flyway:
       baselineOnMigrate: false
       locations: classpath:db/migration
       enabled: true
     shardingsphere:
       datasource:
         names: testshard
         testshard:
           type: com.alibaba.druid.pool.DruidDataSource
           driverClassName: org.mariadb.jdbc.Driver
           url: 
jdbc:mariadb://localhost:3306/test_shard?useUnicode=yes&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
           username: root
           password: ******
       sharding:
         tables:
           example:
             actual-data-nodes: 
testshard.example_20221,testshard.example_20214,testshard.example_20213
             table-strategy:
               standard:
                 sharding-column: shardColumn
                 precise-algorithm-class-name: 
com.example.demo.MyPreciseShardingAlgorithm
                 range-algorithm-class-name: 
com.example.demo.TimeRangeShardingAlgorithm # The fully qualified class name of 
the implementation class
             key-generator:
               column: id
               type: SNOWFLAKE
       props:
         sql:
           show: true
   
   **Below are the sbt dependency details and logs:**
   
   "org.apache.shardingsphere" % "sharding-jdbc-spring-boot-starter" % "4.1.1"
   "org.apache.shardingsphere" % "sharding-core-common" % "4.1.1"
   "com.alibaba" % "druid" % "1.2.4"
   
   flyway 6.4.2
   
   **DDL query trying to execute via Flyway:** 
   
   ALTER TABLE `test_shard`.`example` ADD COLUMN last_name varchar(64) NULL;
   
   **Spring boot start up logs:**
   
   Flyway Community Edition 6.4.2 by Redgate
   o.f.c.internal.database.DatabaseFactory  : Flyway Community Edition 6.4.2 by 
Redgate
   o.f.c.internal.database.DatabaseFactory  : Database: 
jdbc:mariadb://localhost:3306/testshard (MariaDB 10.4)
   o.f.core.internal.command.DbValidate     : Successfully validated 747 
migrations (execution time 00:04.875s)
   o.f.core.internal.command.DbMigrate      : Current version of schema 
`testshard`: 2.653
   o.f.core.internal.command.DbMigrate      : Migrating schema `testshard` with 
repeatable migration
   o.f.core.internal.command.DbMigrate      : Successfully applied 1 migration 
to schema `testshard` (execution time 00:02.639s)
   Database: jdbc:mariadb://localhost:3306/testshard (MariaDB 10.4)
   o.f.core.internal.command.DbValidate     : Successfully validated 747 
migrations (execution time 00:04.875s)
   o.f.core.internal.command.DbMigrate      : Current version of schema 
`testshard`: 2.653
   o.f.core.internal.command.DbMigrate      : Migrating schema `testshard` with 
repeatable migration
   o.f.core.internal.command.DbMigrate      : Successfully applied 1 migration 
to schema `testshard` (execution time 00:02.639s)
   
   tables:
     example:
       actualDataNodes: 
testshard.example_20221,testshard.example_20214,testshard.example_20213
       keyGenerator:
         column: id
         type: SNOWFLAKE
       logicTable: example
       tableStrategy:
         standard:
           preciseAlgorithmClassName: 
com.example.demo.MyPreciseShardingAlgorithm
           rangeAlgorithmClassName: com.example.demo.TimeRangeShardingAlgorithm
           shardingColumn: shardColumn
   
   o.a.s.core.log.ConfigurationLogger       : Properties:
   sql.show: 'true'
   
   ShardingSphere-metadata                  : Loading 1 logic tables' meta data.
   ShardingSphere-metadata                  : Loading 5 tables' meta data.
   ShardingSphere-metadata                  : Meta data load finished, cost 115 
milliseconds.
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to