Quantcast
Channel: Liquibase Forums
Viewing all 2993 articles
Browse latest View live

Re : Merging ChangeSets

$
0
0
I developped a simplee piece of code which is able to handle this requirement.
  • First, I describe with a config file, that ChangeSet C is equivalent to ChangeSet A + ChangetSet B
  • Then, at runtime, prior to running Liquibase#update, I update the CHANGELOG table:
    • If A and B have been run, then I insert C as Executed to prevent it from being run
    • If A or B have been run, then I insert C as Executed and let A or B (the other one) run normally
    • If either A nor B have been run, then I insert A and B as Executed and let C run normally

I wonder whether this feature could find its way to Liquibase Core code?


Re : Create Index and order

$
0
0
I've submitted a pull request that will make it possible to specify descending key columns not only for indexes, but also for primary keys and unique constraints. This will even work on databases with quoted column names like Microsoft SQL Server. If it's accepted, it could make it into Liquibase 3.4.0.

Here is an example of how it could work:

<createIndex tableName="my_table" indexName="my_index">
    <column name="col1"/>
    <column name="col2" descending="true"/>
</createIndex>

<addPrimaryKey tableName="my_table" columnNames="col1, col2 DESC"/>

<addUniqueConstraint tableName="my_table" columnNames="col1, col2 DESC"/>

Parse sql script

$
0
0
Hi all,

i want to parse a sql file, which contains for example

"CREATE TABLE [Meeting] ([pkMeeting] INT NOT NULL, [Name] VARCHAR(50), CONSTRAINT [PK_tblMeeting] PRIMARY KEY ([pkMeeting]));" ,

over liquibase in java, so i can use getters for the tablename or columnname(s). Is that possible?

I just found classes like "CreateTableStatement", but maybe i'm completely wrong with this approach?

The other way round to generate the sql script over liquibase with the "SqlGeneratorFactory" and the "CreateTableChange" with its "ColumnConfigs" and "ConstraintsConfigs" was successful.

I hope someone can help me.

Best regards
K

Re : Parse sql script

$
0
0
I think you are asking if Liquibase can parse SQL - the answer is no, it cannot. 

It is able to generate SQL (customized for each of the different database platforms it supports) starting from a more general 'language' (the changelog, which can be in XML, YAML, or JSON), but it does not currently have support for going the other way. 

There is a 'round-about' way of getting there, which is to apply the SQL to a database using whatever tools that database provides, and then you can use Liquibase's 'diffChangeLog" command to generate a changelog, which is something that could be loaded into Liquibase's "Database Schema Model", where you could do things like use java to enumerate all the database objects, etc. 

Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/

MySqlSyntaxErrorException: table already exists

$
0
0

I have seen several related questions and their answers, but it is not helping my case.

I have a Spring boot application, where I have created entities using Jhipster, plus I have added some manual changelog changesets myself.

I have a Doctor entity, which contains a One-to-Many uni-directional relationship with 'Specialty' where 'Doctor' is the owner of the relationship. So I specified a Join table that will store Doctor and Specialty foreign keys.

@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinTable(
        name="T_DOCTOR_SPECIALTY",
        joinColumns = @JoinColumn( name="doctor_id"),
        inverseJoinColumns = @JoinColumn( name="specialty_id")
)
private List<Specialty> specialties = new ArrayList<>();

For this, I added a changelog file, that even contains the tag to ignore specialty if it already exists,

<changeSet id="20150415081455" author="waqas">
    <preConditions onFail="MARK_RAN">
        <not>
            <tableExists tableName="T_DOCTOR_SPECIALTY"/>
        </not>
    </preConditions>
</changeSet>

<changeSet id="20150415081221" author="waqas">

    <createTable tableName="T_DOCTOR_SPECIALTY">

        ...

Then, I create a new database with no tables and run the application, but I get the following exception:

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 't_doctor_specialty' already exists
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_40]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:...



Re : Date and Time types for MSSQL

$
0
0
CORE-2217  which is due for Liquibase 3.4.0 will vastly improve support for SQL Server data types including these date/time types. I've added a rigorous test suite that encompasses all built-in types. Have a look at the merged pull request #398 .

Re : Liquibase doesn't honor type modifiers

$
0
0
This will be fixed in 3.4.0 with CORE-2300 . There's now a test case that will prevent it from breaking. See pull request #401 .

Re : Liquibase doesn't honor type modifiers

$
0
0
@mches That pull request only deals with UNSIGNED modifiers, not ZEROFILL.

Rollback to changeset - does changeSetPath work?

$
0
0
I'm trying to roll back using a previous changeset, i.e.

<rollback changeSetId="mychangeset" changeSetAuthor="elvisp" changeSetPath="changelogs/xxx/testchangelog.xml" />

The changeSetPath doesn't seem to work, I've tried various option here.
I can only refer to changesets that are contained in the local change log.

I found bug CORE-871 which is the issue I'm seeing but this should have been fixed in the version I'm using (3.2.2).

Has anyone had any success in getting this to work, if so could you provide an example?

Managing database snapshots with liquibase

$
0
0
I'm dealing with following scenario:
I have two types of databases with different purposes: demo and dev. I'm maintaining the changelog file with all DDL changes and some technical data changes (My application stores some configuration data in the db). I also want to store somewhere my demo data. So ideally it could be obtained by storing all the db changes in the changelog (with different contexts) BUT: the data in the demo instance are inserted via application, not only by developers but also others people from the project. Additionally the db schema is quite large and inserting one entity results with inserting records in several different tables. Therefore managing such changelog for the demo data is very difficult and time consuming. 
So I want to be able to make a full demo database snapshot on demand and store it in the project to be not dependent of external db instance. 
Can liquibase help me in such case? 
I've considered the following solutions:
  1. Maintaining DDL's in changelog file and all the data in demo.snapshot file with 'demo' contexts. So if I want to create new demo instance on empty db I can run first the ddl's and then load the demo data. But I dismiss this solution because it works only when the snapshot is done from the newest db schema. If I take a snapshot of demo and then I add some DDL's I will not be able to insert old data on new db schema.
  2. Maintaining all DB changes (DDL's + technical data, not including demo data) in changelog and store dump of whole demo db (including DDL's). So if I want to create new demo instance on empty db I will run the dump file and liquibase:update command. Disadvantage of this solution is that I must use external tool to generate such snapshot (or liquibase can help? I tried with generateChangeLog command but it omits the DATABASECHANGELOG table so the liquibase:update command will crash)
Have you dealed with such case and found solution? I'll be thankful for any advice.

Additional constraints:
  • I started with existing database but I solved it by creating the 'initial' context with the initial state.
  • As I mentioned I want to be able to create the dev db instance with only technical data included
Regards,
Adam

How to generate changelog of data for selected tables only?

$
0
0
Hi All,

Is there any way Liquibase can generate changelog of data for selected tables only? I need to create a baseline of data that are only for reference.

Thanks :)

"rollback" feature using "SQL formatted output" does not work as expected in Liquibase 3.3.0 (Oracle DB)

$
0
0
I am facing an issue with using the "rollback" feature in a "formatted SQL output" file.

My SQL file consists of the following changesets:
  • CS1 = Create table with a rollback to drop table
  • CS2 = Create index on column in table created by CS1 with an empty rollback
  • CS3 = Alter table created by CS1 with an empty rollback
  • CS3 = Insert data into table created by CS1 with an empty rollback

I was able to update the DB successfully to apply the above changesets. However when I attempt to roll-back I encounter the following error for CS4's rollback:
"Unexpected error running Liquibase: No inverse to liquibase.change.core.RawSQLChange created"

Assuming the above error was due to the empty rollback (which I expected should have worked in the first place), I modified the rollback for CS4 to delete the row I inserted, but then encountered an error that "liquibase: Validation Failed" due to the differing check sum (although I read another post from 4 years ago that stated that rollback statements are not part of the check sum calculation.

Questions:
  • Are empty rollback statements not allowed in "SQL formatted output"
  • Are rollback statements now part of the check sum calculation?

Re : "rollback" feature using "SQL formatted output" does not work as expected in Liquibase 3.3.0 (Oracle DB)

$
0
0
Looks like I found an answer to my 1st question "Are empty rollback statements not allowed in "SQL formatted output""


"--rollback not required" is what I need. See the following discussion for more about how this came about



Can this be added to the official Liquibase documentation?

Liquibase-3.3.0 -- not working with JBoss vfs

$
0
0
Hi

I have been using Liquibase 2.0.2 and it has been great! Thanks for the wonderful tool.

However, after upgrade to 3.3.0, liquibase start to fail on JBoss EAP 6, when trying to load osgi jar file. I think it is because JBoss use vfs to load file and so does the classpath:

vfs:/E:/JAVA/JBOSS/EAP-6.0.0.GA/jboss-eap-6.0/standalone/deployments/My.App.version.01.war/WEB-INF/lib/liquibase-osgi-3.3.0-SNAPSHOT.jar

So when org.liquibase.util.FileUtl tries to open the jar file

File tempDir = File.createTempFile("liquibase-unzip", ".dir");

tempDir.delete();

tempDir.mkdir();


JarFile jarFile = new JarFile(zipFile);


please note the zip file is "vfs:/E:/JAVA/JBOSS/EAP-6.0.0.GA/jboss-eap-6.0/standalone/deployments/My.App.version.01.war/WEB-INF/lib/liquibase-osgi-3.3.0-SNAPSHOT.jar"



then it throws an error:


vfs:/E:/JAVA/JBOSS/EAP-6.0.0.GA/jboss-eap-6.0/standalone/deployments/My.App.version.01.war/WEB-INF/lib/liquibase-osgi-3.3.0-SNAPSHOT.jar' for classes due to an IOException: vfs:\E:\JAVA\JBOSS\EAP-6.0.0.GA\jboss-eap-6.0\standalone\deployments\My.App.version.01.war\WEB-INF\lib\liquibase-osgi-3.3.0-SNAPSHOT.jar (The filename, directory name, or volume label syntax is incorrect)


I am sure the file exist in the classpath however either Jboss or liquibase failed to load the file.


please help thanks


Support for descending key columns on indexes, unique constraints and primary keys

$
0
0
I have implemented a pull request PR#407 which adds support for descending key columns on indexes, unique constraints and primary keys. The change log functionality works as expected.

I started implementing the necessary snapshot logic, however I have observed that the Index#getColumns() are essentially being replaced with Table#getColumns() by DatabaseSnapshot#includeNestedObjects(DatabaseObject). The table columns don't have the "descending" attribute set. Therefore, when the MissingIndexChangeGenerator runs, it won't have access to the "descending" attribute and all the index key columns are treated as ascending.

I'd appreciate any feedback on the current changes and advice on how to make forward progress on the snapshot changes.

Error when trying to generateChangeLog : ORA-00942: table or view does not exist

$
0
0
I'm trying to generate a change log for a schema on a database.

I get an error, but can't figure out what the problem might; there is no detail in the message.

The schema contains tables, views, packages, etc

Liquibase Version: 3.3.2
Java: 1.8.0_40

Oracle Database 11g Enterprise Edition, v 11.2.0.4.0

Maybe someone has an idea how to log more details or what might be the problem.



./liquibase --logLevel=debug --driver=oracle.jdbc.OracleDriver --classpath=.........\ojdbc6.jar --url=jdbc:oracle:thin:@//zzzzzz:1521/service --username=xyz --password=passwd --changeLogFile=mychangelog.xml generateChangeLog
Liquibase Home is not set.
DEBUG 30-04-15 13:03: liquibase: Connected to xyz@jdbc:oracle:thin:@//zzzzzz:1521/service
DEBUG 30-04-15 13:03: liquibase: Setting auto commit to false from true
DEBUG 30-04-15 13:03: liquibase: Computed checksum for 1430391797690 as dd44bb7b428ad16e2ec12ac83cea2d67
Unexpected error running Liquibase: liquibase.exception.DatabaseException: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist


SEVERE 30-04-15 13:03: liquibase: liquibase.exception.DatabaseException: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist

liquibase.exception.LiquibaseException: liquibase.command.CommandExecutionException: liquibase.exception.DatabaseException: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist

        at liquibase.integration.commandline.CommandLineUtils.doGenerateChangeLog(CommandLineUtils.java:155)
        at liquibase.integration.commandline.Main.doMigration(Main.java:951)
        at liquibase.integration.commandline.Main.run(Main.java:175)
        at liquibase.integration.commandline.Main.main(Main.java:94)
Caused by: liquibase.command.CommandExecutionException: liquibase.exception.DatabaseException: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist

        at liquibase.command.AbstractCommand.execute(AbstractCommand.java:13)
        at liquibase.integration.commandline.CommandLineUtils.doGenerateChangeLog(CommandLineUtils.java:153)
        ... 3 more
Caused by: liquibase.exception.DatabaseException: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist

        at liquibase.snapshot.jvm.CatalogSnapshotGenerator.snapshotObject(CatalogSnapshotGenerator.java:53)
        at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:60)
        at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50)
        at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:163)
        at liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:55)
        at liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:37)
        at liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:25)
        at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:126)
        at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:119)
        at liquibase.command.DiffCommand.createReferenceSnapshot(DiffCommand.java:190)
        at liquibase.command.DiffCommand.createDiffResult(DiffCommand.java:140)
        at liquibase.command.GenerateChangeLogCommand.run(GenerateChangeLogCommand.java:45)
        at liquibase.command.AbstractCommand.execute(AbstractCommand.java:8)
        ... 4 more
Caused by: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist

        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
        at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:837)
        at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
        at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
        at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523)
        at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:193)
        at oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:852)
        at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1153)
        at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1275)
        at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1477)
        at oracle.jdbc.driver.OracleStatementWrapper.executeQuery(OracleStatementWrapper.java:392)
        at oracle.jdbc.OracleDatabaseMetaData.getSchemas(OracleDatabaseMetaData.java:3105)
        at liquibase.snapshot.jvm.CatalogSnapshotGenerator.getDatabaseCatalogNames(CatalogSnapshotGenerator.java:78)
        at liquibase.snapshot.jvm.CatalogSnapshotGenerator.snapshotObject(CatalogSnapshotGenerator.java:41)
        ... 16 more


For more information, use the --logLevel flag

Re : Error when trying to generateChangeLog : ORA-00942: table or view does not exist

$
0
0
Looking at the code for CatalogSnapshotGenerator.getDatabaseCatalogNames and what calls that, here is what is happening, and what I suspect may be the problem.

1. In order to generate a changelog, what liquibase does is compare an abstract model of two databases to each other.
2. In order to generate the abstract models of the databases, it makes a variety of queries to the databases.
3. One of the queries is to get the names of the catalogs on the database (Different databases have different names for these - Oracle calls these schemas)
4. When it tries to get the list of schemas, Oracle returns an error that a table doesn't exist. Since Oracle doesn't say what table you were querying, it is difficult to tell exactly what is happening, but my suspicion is that the user you are using in the Liquibase connection information doesn't have sufficient permissions to read the database-level schema information. In general, on Oracle, the user should have the 'DBA' role or something pretty close to that. 



Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/

Working on setting up new Database (NuoDB) on liquid base

$
0
0
Hi,

I am completely new to LiquidBase. I am working on setting up NuoDB on LiquidBase.

NuoDB is a relational database which can be scalable and it has several other features. Please help on how to begin first?

Thanks!!

Re : Error when trying to generateChangeLog : ORA-00942: table or view does not exist

$
0
0
Hi,

thanks for the explanation.

Is there any work-around?

We are in a environment where we can't get such grants (dba or close is not possible).


Developer tools (toad, sql developer) appear to be able to do without this information, so why does liquibase need it? Just wondering.

/jørgen

databasechangelog.csv: wrong format in latest git?

$
0
0
I programmatically generate sql by calling update(..., writer) in combination with a OfflineConnection. This has worked great until recently.

With the latest update from git, I get:

java.lang.ArrayIndexOutOfBoundsException: 11

Stack trace:
liquibase.exception.DatabaseException: java.lang.ArrayIndexOutOfBoundsException: 11
  at liquibase.changelog.OfflineChangeLogHistoryService.appendChangeSet(OfflineChangeLogHistoryService.java:282)
  at liquibase.changelog.OfflineChangeLogHistoryService.setExecType(OfflineChangeLogHistoryService.java:318)
  at liquibase.database.AbstractJdbcDatabase.markChangeSetExecStatus(AbstractJdbcDatabase.java:1096)
  at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:62)
  at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:73)
  at liquibase.Liquibase.update(Liquibase.java:208)
  at liquibase.Liquibase.update(Liquibase.java:271)
  at liquibase.Liquibase.update(Liquibase.java:252)


The databasechangelog.csv looks like this, I think liquibase tries to index it at 11, but there isn't enough fields...

"ID","AUTHOR","FILENAME","DATEEXECUTED","ORDEREXECUTED","EXECTYPE","MD5SUM","DESCRIPTION","COMMENTS","TAG","LIQUIBASE"

Ideas?

Thanks.
Viewing all 2993 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>