liquibase data generate ChangeLog with extra spaces - liquibase

I am migrating data from mssql to oracle.Now I generated the changeLog for mssql by specifying the diff type data.I got the following
<insert tableName="TEST_TABLE">
<column name="test_column" value="TEST_value "/>
</insert>
But Test_value contains too many spaces which I don’t have in my mssql database.It has generated extra spaces.Could any one please help me out this why I got extra spaces

Related

Why is liquibase changeset not used with liquibase maven plugin update

using liquibase inside a spring boot project in combination with the liquibase maven plugin.
I'v added the following changeset:
<changeSet author="mrx" id="1642181924202-55">
<addColumn tableName="users" >
<column name="email"
type="varchar(255)">
</column>
</addColumn>
</changeSet>
The liquibase properties:
url=jdbc:mysql://db:3306/mydb
username=root
classpath=mysql-connector-java-8.0.12.jar
password=test
ChangeLogFile=liquibaseChangeLog.xml
driver=com.mysql.cj.jdbc.Driver
outputChangeLogFile=src/main/resources/liquibaseChangeLog.xml
diffExcludeObjects=table:ACT_.*
logLevel=finest
diffTypes=data,tables,views,columns,indexes,foreignkeys,primarykeys,uniqueconstraints
in application.yaml of spring boot:
liquibase:
change-log: classpath:liquibaseChangeLog.xml
And then I'm running from intellij the maven liquibase plugin action "update" but the table is not altered and the changelog does not contain the -55 id so it is not used.
The changelog was generated before from an existing DB, this worked and when I delete the whole DB liquibase recreates it. Only cannt add one simple column here by hand.
How can I get this to work? Is my changeset missing some info? (I deleted parameters schema and catalog, seemed like I did not need them and I wouldnt know what to fill in, the id is just the same as the last generated one +1) That the changeset adds actually a simple column like this.
ok, I ran all the time liquibase update and it did not work but after I simply build the project and started the spring boot app, the changelog was applied correctly. :/

Liquibase - Generating Change Logs

I want Liquibase, to generate a changelog, from this DB 'testing'. Is it possible?
I have an existing database already, with its tables and data inside.
jdbc:mysql://localhost:3306/testing
Now, I want Liquibase, to generate a changelog, from this DB 'testing'. Is it possible?
This is my command, but it doesn't work.
liquibase --driver=com.mysql.jdbc.Driver --classpath=C:\mysql-connector-java-5.1.47.jar
--changeLogFile=C:\db.changelog.xml --url="jdbc:mysql://localhost:3306/testing"
--username=root generateChangeLog
I don't use any password.
The error is related to --changeLogFile=C:\db.changelog.xml
I thought, Liquibase will refer to my DB 'testing', and generate changelog, with name 'db.changelog.xml' in folder C.
Which part I'm wrong? Do I miss something?
Or maybe, Liquibase is not intended, to generate changelog, from existing DB?
Or maybe, Liquibase is intended, to generate DB, from changelog only? And not vice versa?
This is possible. You might be having trouble since you are writing to a file in the root of your c: drive. Try c:\temp\changelog instead.
My experience is that liquibase works in increments. So if you run that command on your database, it will produce a file as if everything in the database has to be created in the changelog file (as if starting with a completely empty database).
If you read the text on Liquibase's site regarding this command, it says:
When starting to use Liquibase on an existing database, it is often useful, particularly for testing, to have a way to generate the change log to create the current database schema.
This means that if you:
Execute this command once against your dev database
Run the result against a new database (let's say test)
Run it again on your dev database
Run that file against your test database
You will get a load of errors stating that functions already exist.
I gather that the idea behind this is that you create new entries in the changelog files and executing them against ALL your databases, instead of using other tools and using liquibase for the delta.
Sample entry
<changeSet author="liquibase-docs" id="addColumn-example">
<addColumn catalogName="cat" schemaName="public" tableName="YY">
<column name="xx" type="varchar(255)"/>
</addColumn>
</changeSet>
SQL equivalent
ALTER TABLE yy ADD COLUMN xx INT

liquibase diffchange log issue repeats the change set

Hi I am facing one issue with diffChangelog.I have performed diffchangelog between two MSSQL databases I got list of change sets.I got following
changeSet author="deekshith (generated)" id="1415884590690-1734">
modifyDataType columnName="lingo_id" newDataType="char(36)" tableName="lingo"/>
addNotNullConstraint columnDataType="char(36)" columnName="lingo_id" tableName="lingo"/>
/changeSet
I have update the change sets to respective database and again performed diffChangelog I got same as above again
changeSet author="deekshith (generated)" id="1415884590690-1736">
modifyDataType columnName="lingo_id" newDataType="char(36)" tableName="lingo"/>
addNotNullConstraint columnDataType="char(36)" columnName="lingo_id" tableName="lingo"/>
/changeSet
Please let me know what I am doing wrong
I think you are mis-understanding what the Liquibase diffChangeLog command does. If you are running it between 2 databases, changing the changelog won't alter the output - what the command does is generate a changelog that you could then use with the Liquibase update command to bring the second database in sync with the first. Any changelog you already have isn't used when running the diffChangeLog command.

Erroneous md5sum failure for liquibase changeSets

We are using liquibase 1.9.5, but I haven't seen this as a known bug for that version. The short story is we successfully ran liquibase for our 1.0 release, but it errors out complaining about the md5sums of the 1.0 changeSets when trying to run our 1.1 release that has additional changeSets.
We've worked around it in the short term by just nulling out the md5sum column in DATABASECHANGELOG, but I'm wondering if I'm just doing something wrong.
We organize our liquibase as follows:
One master .xml file that we run on every deployment, which just has commands for a separate file for each version of our software (in the correct order)
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9 http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
<include file="v1_0.xml" />
<include file="v1_1.xml" />
</databaseChangeLog>
So the first release only included v1_0.xml, and the release we just pushed out included what we have above.
The v1_0.xml file was unchanged between releases, but we got the following error when trying to invoke liquibase for the new release:
SEVERE: Validation Failed:
1 change sets check sum
v1_0.xml::foo_schema::bdeacon::(MD5Sum: ff63b8d1739e6cf1dcaed6a0ef585257)
The changeSet in question:
<changeSet author="bdeacon" id="foo_schema">
<preConditions onFail="MARK_RAN">
<not><tableExists tableName="some_table"/></not>
</preConditions>
<sqlFile path="database/initial/foo-schema.sql" />
</changeSet>
The foo-schema.sql file referred to was also unchanged between releases. (It does the initial creation of our entire database schema for us, which then includes the "some_table" mentioned in the precondition.)
I would hope liquibase isn't expecting us to manually add a validCheckSum element to every changeSet between releases...
You should not need to add a validCheckSum unless the contents of the changeSet or the sql file changes.
Is there anything such as a SVN version number or whitespace/line endings that may be changing in the foo-schema.sql?
You can set “runOnChange” changeSet attribute to true. In that case, whenever any sql file that is referenced by changeset is changed that changeset will be run again and its checksum will be updated. See ChangeSet Check Sums section in liquibase doc. It is especially useful when package/procedure/trigger code is using a statement like "CREATE OR REPLACE" in which case you would not need to precede the calls to sql files with drop statements to avoid "..already exists" errors.

Converting a "DBML" file to a "SQL database file"

I have the DBML file of a database and would like to generate an SQL database file from this file.
Thanks
There's a method on the Data Context called CreateDatabase() that you could use.
http://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.createdatabase.aspx
I know of no available utilities that do that, and it's a bit much to do for a SO answer.
But, for the most part, it's not that big a deal. The DBML file is written in XML; it should be easy to read via Linq-to-xml. Then just split out the SQL commands for the values in the xml into a script file. Then run the script. (It also could be done with a XSLT transformation)
<Table Name="dbo.Person" Member="Persons">
becomes
CREATE TABLE Persons (
and
<Column Name="PersonID" Type="System.Int32" DbType="Int NOT NULL IDENTITY"
IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false">
</Column>
<Column Name="AddressID" Type="System.Int32" DbType="Int NOT NULL"
CanBeNull="false"></Column>
becomes:
PersonID Int NOT NULL,
AddressID int NOT NULL,
and so on.
You can use the CLI tool.
dbml2sql schema.dbml -o schema.sql
https://www.dbml.org/cli/#convert-a-dbml-file-to-sql