add
heheng
2025-06-10 942bdeee0b6fcc92b35e788c851d39c5182a8e40
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.gkhy.exam.common.config;
 
import cn.hutool.extra.spring.SpringUtil;
import lombok.extern.slf4j.Slf4j;
import org.flywaydb.core.Flyway;
 
import javax.sql.DataSource;
 
 
@Slf4j
public class BaseFlywayConfig {
    public void initDataSource(String dataSourceName){
        Flyway flyway = Flyway.configure()
                .dataSource(SpringUtil.getBean(dataSourceName,DataSource.class))
                .locations("classpath:db/migration")
                .encoding("UTF-8")
                .outOfOrder(true)
                .cleanDisabled(true)
                .cleanOnValidationError(false)
                .sqlMigrationPrefix("V")
                .sqlMigrationSeparator("_")
                .sqlMigrationSuffixes(".sql")
                .validateOnMigrate(true)
                .baselineOnMigrate(true)
                .load();
        flyway.migrate();
    }
}