Is there a way to include whole folder with changelogs in Liquibase db versioning? - azure-devops

I have a problem with Liquibase database versioning, because I want to include all changelog files in folder, without specifing its names and do update using them. Is that possible? My structure:
db--
|
--release-v1
|
--fistchangelog.sql
--secondchangelog.sql
|
--release-v2
|
--newchangelog.sql
...
And with every release I want to use all *.sql files from its folder. I don't want to hardcode names of sql files. I use only liquibase command lines for CI/CD in Azure.
I found something like (liquibase.org/get-started/best-practices), but it only works with xml files and I use sql extension.
I have one idea but it seems bad for me and I ll use it as a last resort. Just making a loop, for every file in folder, in cmd...
Does someone know is there a simpler and better way?

You can do like this:
have a parent change log file:
databaseChangeLog = {
include file: "releases/ref1.groovy", relativeToChangelogFile: true
include file: "releases/release1.groovy", relativeToChangelogFile: true
include file: "releases/release2.groovy", relativeToChangelogFile: true
include file: "releases/release3.groovy", relativeToChangelogFile: true
}
in releases folder ref1 file can have:
databaseChangeLog = {
include file: "../tables/changelog.groovy", relativeToChangelogFile: true
}
So inside the same releases folder you can have tables folder which then have create, delete update folders. So you can have another file in tables like, in create folder, you have all the necessary files that have been added in different releases:
databaseChangeLog = {
include file: "create/changelog.groovy", relativeToChangelogFile: true
include file: "update/changelog.groovy", relativeToChangelogFile: true
include file: "data/changelog.groovy", relativeToChangelogFile: true
}
finally in releases main folder you can add a file like release1.groovy:
databaseChangeLog = {
include file: "../tables/create/your_structured_sql_file.groovy",
relativeToChangelogFile: true
}
These are in groovy but the structuring is the same.

i think you should just use "includeAll" tag. Then liquibase will execute all .sql files inside the folder. but remember that if you not specifying every single file, Liquibase will execute those files in alphabetical order.
Sth like:
<includeAll path="com/example/changelogs/"/>
Read here -> https://docs.liquibase.com/concepts/changelogs/attributes/includeall.html

Related

how to regenerate meson for newly added yaml files

I have added yaml files to add new dbus objects and I added PHOSPHOR_MAPPER_SERVICE_append = " com/newCoName"
(newCoName is the name of my company)
But when I run bitbake, do_configure for phosphor_mapper bails when it passes the option -Ddata_com_newCoName to meson. The following readme says I need to run ./regenerate_meson from the gen directory when I add new YAML files. But how do I do that from a recipe file?
https://github.com/openbmc/phosphor-dbus-interfaces
One option is to generate these files outside ot yocto environment (i.e. not involving bitbake). Thus
clone that git repo
place your yaml file where you cloned repo
do what readme tells, i.e. go to gen directory and execute meson-regenerate script
collect changes that are done by script and create patch
add patch to your layer and reference it in .bbappend file (meta-/recipes-phosphor/dbus/phosphor-dbus-interfaces_git.bbappend)
Another option would be to add to .bbappend file additional task that runs before do_configure - and call that script from there:
do_configure_prepend() {
cd ${S}/gen && ./meson-regenerate
}
Along this .bbappend you should add your yaml so that it lands inside gen folder in patch or directly in your layer (check FILESEXTRAPATHS).
In both cases you'll need to patch meson_options.txt: add option
option('data_com_newCoName', type: 'boolean', value: true)

Old feature file path is used even after updating a new path

I am new to cucumber and I am automating a scenario. Initially I kept my features files in the path C:\Users\test\eclipse-workspace\Automation\src\test\resources\featureFile. Then I moved the feature files to a different path (C:\Users\test\eclipse-workspace\Automation\src\test\com\test]automation\features). I have updated the same in CucumberOptions as shown below.
#CucumberOptions(features = {
"src/test/java/com/test/automation/features/CO_Self_Service_Home_Page_Personalizations.feature" }, glue = {
"src/test/java/com/oracle/peoplesoft/HCM/StepDefinitions" })
But when I try to run the feature, I am getting the below exception stating the feature file is not found. Here the path shown in the exception is the old path. I am not sure from where it is fetched as I have updated the new path in Cucumber options. Can you please help me understand the cause of this issue.
Exception in thread "main" java.lang.IllegalArgumentException: Not a
file or directory:
C:\Users\test\eclipse-workspace\Automation\src\test\resources\featureFile\Self_Service_Home_Page_Personalizations.feature
at
cucumber.runtime.io.FileResourceIterator$FileIterator.(FileResourceIterator.java:54)
at
cucumber.runtime.io.FileResourceIterator.(FileResourceIterator.java:20)
at
cucumber.runtime.io.FileResourceIterable.iterator(FileResourceIterable.java:19)
at
cucumber.runtime.model.CucumberFeature.loadFromFeaturePath(CucumberFeature.java:103)
at
cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:54)
at
cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:34)
at
cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:235)
at cucumber.runtime.Runtime.run(Runtime.java:110) at
cucumber.api.cli.Main.run(Main.java:36) at
cucumber.api.cli.Main.main(Main.java:18)
There are a couple of points you need to take care as follows :
As per Best Practices cerate the directory features which will contain the featurefile(s) strictly through your IDE only (not through other softwares Notepad or Textpad or SubLime3) as per the image below (New -> File) :
Create the featurefile i.e. CO_Self_Service_Home_Page_Personalizations.feature within features directory strictly through your IDE only.
Keep your Project Structure simple by placing the directory containing the featurefile(s) just under Project Workspace. For Featurefiles Cucumber works with directory names. So create the features directory just under your project space Automation (same hierarchy as src). So the location of the Self_Service_Home_Page_Personalizations.feature will be :
C:\Users\test\eclipse-workspace\Automation\features\Self_Service_Home_Page_Personalizations.feature
Again, as in your Class file containing #CucumberOptions you have mentioned glue = {"StepDefinitions" } ensure that the Class file containing #CucumberOptions must be in the similar hierarchy as the figure below :
So your CucumberOptions will be as follows :
#CucumberOptions(features = {"features" }, glue = {"StepDefinitions" })
Execute your Test
Note : Do not move/copy feature file(s)/directory(ies). Delete the unwanted and create a new one through your IDE only.

Group Item: cannot install file to same location

In my project, I have several plugins depending on a single module, containing a Group item similar to:
Group {
name: "group"
qbs.install: true
qbs.installDir: "../"
files: <filename>
}
But compilation fails with "error: Cannot install files 'filename' and 'filename' to the same location 'location'". Basically, qbs cannot copy same file to same location twice (seems illogical to me)
How can this bug be resolved or is there any elegant workaround?
This is a job for the qbs.installSourceBase property. Basically, you set this to the base directory containing the files in your Group, and Qbs will install the listed files into qbs.installDir hierarchically based on their paths relative to the aforementioned base directory.
For example, given the following Group:
// defined in /source/myproject/myproject.qbs
Group {
qbs.install: true
qbs.installDir: "share/stuff"
qbs.installSourceBase: "." // relative to /source/myproject
files: [
"fileA.txt",
"fileB.txt",
"subdir/fileB.txt",
]
}
and the following command line invocation:
$ qbs [...] --install-root /sample/some-root
the following filesystem hierarchy will result:
/sample/some-root/share/stuff/fileA.txt
/sample/some-root/share/stuff/fileB.txt
/sample/some-root/share/stuff/subdir/fileB.txt
See the Qbs Installation Properties documentation for more info.
There is a workaround, which may require some restructuring of a project:
instead of:
Module {
name: "somemodule"
// module properties set to dependant products
Group {
// files to install
qbs.install: true
}
}
we can use:
Product {
name: "somemodule"
Group {
// files to install
qbs.install: true
}
Export {
// module properties set to dependant products
}
}
This way, files are only installed once when steps for mymodule are run, thus eliminating the conflict. Module properties, exported via Export Item, work just as ones exported via Module.
Limitations:
Product has to be added to references of the Project Item
Modules cannot depend on Product Items, which may require to restructure all dependant modules into Project/Export pairs too

How do I change ownership/attributes of a single file or single folder with sbt-native-packager for an RPM?

sbt-native-packager, when making an RPM, correctly assigns file ownership as root:root for most files. I have a case where exactly one configuration file (which doesn't exist in the RPM file, although it could be added if doing so make it easier) needs to be writable by the service. The easiest way to do this is to change ownership of the conf folder itself, allowing the service to later create that file. The alternate way is to add the file to the RPM and change ownership of just that one file.
I know I can change the ownership of all configuration files with a stanza like this:
linuxPackageMappings in Rpm := {
linuxPackageMappings.value map {
case linuxPackage if linuxPackage.fileData.config equals "true" =>
val newFileData = linuxPackage.fileData.copy(
user = "newuser",
group = "newgroup"
)
linuxPackage.copy(fileData = newFileData)
case linuxPackage => linuxPackage
}
}
But: 1) That doesn't change ownership of the conf folder itself, and 2) That changes ownership of every single file that is a conf file, which I don't want to do. Anyway, no matter what I try, the spec file still has:
%dir %attr(0755,root,root) /path/to/application/conf/
The problem is that it's still owned by root:root. Here is what I tried, for changing ownership of just the one file (using the above stanza with this case):
case linuxPackage if linuxPackage.mappings.head._2 equals "/path/to/application/conf/" =>
Also (the answer may be the same), how can I change exactly one configuration file -- selected by filename -- to withConfig("noreplace") but not the rest? I've figured out that linuxPackageMappings is an instance of Seq[com.typesafe.sbt.packager.linux.LinuxPackageMapping], and each instance of LinuxPackageMapping can have one or more file mappings. I haven't figured out how to remove one mapping from a LinuxPackageMapping and create a new LinuxPackageMapping that contains just the one file. (Or there may be a better way to do this?)

How to change a file name based on the directory it is in for packaging

I have the following gradle task:
task copyToDeployDir(dependsOn: preDeploy) << {
copy {
from codeDir
into deployDir
}
}
This works great for copying from my code dir (usually main or src) into a deployment directory. However, I want to rename a few of these files. Specifically, since I'm using CodeIgniter, I want to rename a couple of the controllers to start with an "install" controller.
Ideally, what I want is to copy over all of the files into deployDir, except any files that are in codeDir/application/controllers, I want to rename to have a suffix of .dist.
I'm not really sure how to go about doing this. I previously tried the renaming stuff in Working with Files in the gradle documentation, but it doesn't seem to work with gradle 2.2.
Try:
task copyToDeployDir(dependsOn: preDeploy, type: Copy) << {
from(codeDir) {
exclude '**/application/controllers/*'
}
from(codeDir) {
include '**/application/controllers/*'
rename {
"${it}.suffix"
}
}
into deployDir
}