Git Product home page Git Product logo

Comments (8)

RomanShkola avatar RomanShkola commented on August 29, 2024 1

I have the master changelog file where the include-tag is placed (there is also relativeToChangelogFile attribure which works correctly), and it includes the file (let's say 'changelog-sql.xml') which contains the stuff I added above:

  <sqlFile dbms="postgresql"
            encoding="utf8" 
	    relativeToChangelogFile="true"
            path="/databasePostgreSQL/001_classicaldbstruct/create_tables.sql"/>

And exactly this changelog-sql.xml causes the error "File doesn't exist".

from liquibase-gradle-plugin.

stevesaliman avatar stevesaliman commented on August 29, 2024 1

There is another solution you can use that should work. It's how I use the plugin with the Groovy DSL, but I'd expect the same behavior with XML.

Gradle is typically run from the project root directory. If you specify all of your paths relative to the project root, you can skip the relativeToChangelogFile attribute and files will still be found. Using my previous example, I could have included my second changelog with a path of src/main/db/changelog/master.xml and without the relativeToChangelogFile. The second changelog could include the SQL with a path of src/main/db/changelog/sql/check.sql, again without the relativeToChangelogFile.

Neither approach is particularly better or worse than the other, just 2 different ways of tackling the same problem.

from liquibase-gradle-plugin.

stevesaliman avatar stevesaliman commented on August 29, 2024

I'm not sure what could be happening here. I have a simple project with a changelog that includes a sql file, and it seems to be working. Exactly what file is liquibase complaining about? could there be a typo in the filename?

from liquibase-gradle-plugin.

stevesaliman avatar stevesaliman commented on August 29, 2024

So if I understand correctly, you have a master changelog, which includes another xml changelog file, which then uses sqlFile. If that is the case, then relativeToChangelogFile looks for files relative to the file that uses the attribute, not the master changelog. Consider the following example:

I have a main changelog named src/main/db/changelog/master.xml. It needs to include another changelog in the src/main/db/changelog/res directory, which it does like this:

<databaseChangeLog>
  <include file="/res/db.changelog-1.0.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

db.changelog-1.0.xml then uses a sql file located in src/main/db/changelog/sql, which it does like this:

<databaseChangeLog>
  <changeSet id="someFile" author="Me">
    <sqlFile path="../sql/check.sql" relativeToChangelogFile="true"/>
  </changeSet>
</databaseChangeLog>

Note hat the res and sql directories are both underneath the changelog directory. In order for this to work, I need to use ../sql in the path and not just /sql. I need a path relative to the res directory where db.changelog-1.0.xml lives because the file including the sql file is not the master changelog file sitting one directory up.

from liquibase-gradle-plugin.

RomanShkola avatar RomanShkola commented on August 29, 2024

Yes, you underestood everything correctly.
So, the example that you have added above should work for sure?

from liquibase-gradle-plugin.

stevesaliman avatar stevesaliman commented on August 29, 2024

I have a working example using the files I mentioned in my previous answer came from a working project, though I did remove the xmlns stuff from the databaseChangeLog tag for brevity.

from liquibase-gradle-plugin.

RomanShkola avatar RomanShkola commented on August 29, 2024

The folder structure is the following:

+ database
├── + databasePostgreSQL
│   └── ...
├── + changelog
│   └── + PROJECT-X.X.X
│   │   └── ...
│   │   └── db.changelog.xml
│   │   └── db.tag.xml
│   └── db.changelog-master.xml
│   └── db.tag-BASELINE.xml

So, as you can see create_tables.sql file is outside the changelog folder. Is it still possible to use relativeToChangelogFile attribute? Maybe different solution?

from liquibase-gradle-plugin.

RomanShkola avatar RomanShkola commented on August 29, 2024

Ok, I resolved it using the following:

<sqlFile dbms="postgresql"
            encoding="utf8" relativeToChangelogFile="true"
            path="../../databasePostgreSQL/001_classicaldbstruct/create_tables.sql"/>
<rollback>

from liquibase-gradle-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.