Comments (3)
Here is my solution:
Environment
Gradle version: 4.1
Plugin version: 1.2.4
build.gradle:
def changeLog = "$projectDir/src/main/resources/db/db.changelog-master.xml"
def getProperties(environment) {
Properties properties = new Properties()
File propertiesFile = new File("$projectDir/.environment/${environment}.properties")
propertiesFile.withInputStream {
properties.load(it)
}
return properties
}
task dbMigration {
doLast {
def environment = System.properties['APP_ENV'] ?: 'local'
println "Migrating ${environment}..."
def properties = getProperties(environment)
liquibase {
activities {
main {
changeLogFile changeLog
classpath "$projectDir/src/main/resources/"
url properties.jdbcUrl
username properties.username
password properties.password
}
}
}
}
}
db.changelog-master.xml:
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<include file="db/changelog/V_20180429165618__db.changelog-create-short-video-table.xml"/>
<include file="db/changelog/V_20180429165618__db.changelog-create-video-metadata-table.xml"/>
<include file="db/changelog/V_20180501121226__db.changelog-create-trigger-after-insert-video.xml"/>
</databaseChangeLog>
Structure:
└── resources
└── db
├── changelog
│ ├── V_20180429165618__db.changelog-create-short-video-table.xml
│ ├── V_20180429165618__db.changelog-create-video-metadata-table.xml
│ └── V_20180501121226__db.changelog-create-trigger-after-insert-video.xml
├── db.changelog-master.xml
├── generator.py
└── sql
├── V_20180501121226__IncreaseStoredProcedure_1.sql
└── V_20180501121226__create_metadata_after_insert_video.sql
And then:
gradle -DAPP_ENV=development dbMigration dropAll update
NOTE:
classpath
is important- Do not use
relativeToChangelogFile
- XML/Groovy/ Etc.. doesn't matter, choose one which fit you. XML Fit me well when using IDEA, there're autocompletion.
from liquibase-gradle-plugin.
Is there a publicly available project that exhibits this behavior? I don't have any projects locally that call liquibase on startup.
The gradle plugin doesn't decide how the filenames show up in the database, so my hunch is that this is in Liquibase itself, but I'd be interested in tracing this through the liquibase groovy dsl to see how it is being asked to load the file during application startup - I might be able to get the plugin to do the same.
from liquibase-gradle-plugin.
Closed due to inactivity, and the fact that later versions of Liquibase have changed how files are handled. If this is still an issue with the latest versions of Liquibase and the plugin, we can always open a new issue.
from liquibase-gradle-plugin.
Related Issues (20)
- Problem with labelFilter argument HOT 1
- Avoiding duplication of properties between spring boot and gradle HOT 1
- With Gradle 7.6.2 and Java 17, Liquibase build throwing 'org.liquibase.gradle.LiquibaseTask' property 'command' is missing an input or output annotation HOT 3
- Is this project still active? HOT 2
- Is there a simple way to disable the plugin? HOT 2
- liquibase-gradle-plugin should declare picocli as a transitive dependency HOT 9
- Generate Changelog with defaultSchemaName not possible HOT 1
- Running Liquibase 4 with Gradle 8 causes error could not find method getMain() for arguments [] HOT 2
- spring boot v3 integration example HOT 5
- micronaut 4 liquibase plugin integration
- Liquibase --username argument should be placed after the command
- Task "updateSQL" ignores "--outputFile" parameter HOT 3
- Upgrade to "org.apache.groovy:groovy" HOT 1
- Java 19
- Liquibase "diffChangelog" suddenly stops generating migration files HOT 2
- markNextChangesetRan not filtering by label HOT 1
- Snakeyaml error when running diffChangelog
- Modify Liquibase Gradle Plugin to handle custom Liquibase extensions HOT 4
- Crashes with 2 errors when configuration cache is enabled
- How disable changelog xml file validation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from liquibase-gradle-plugin.