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

Re : Edition Based Redefinition from Oracle and liquibase plugin 3.8.1

$
0
0
Thanks! Datical, the company I work for, has recently committed more resources to maintaining Liquibase. One area we are putting more efforts into is the documentation, so if there are specific areas that are missing information or that are confusing, please let me know and we will address it. 

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

loadData + CSV + computedValue

$
0
0
Hi,

we are inserting bunch of data using CSV and have generated IDs everywhere.
To insert records that reference other records there is possibility to use computedValue.
This works just fine when using 'insert' (i.e. <column name="abc" valueComputed="SELECT...."/>
but when using 'loadData' it is not.
Even after specifying type="COMPUTED" (<column name="abc type="COMPUTED")
I can see its is properly picked up BUT
computed value.

Are we doing something wrong or is this not supported at the moment?

Thanks,
Zbynek


Re : Detecting Failed Change Sets During automated build process

$
0
0
Hi Erik - just wondering if you are still experiencing this issue with current versions of Liquibase, and if so, what version and database you are using?

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

is it possible for @liquibase to auto-generate changeset Id's? The ID field in [DATABASECHANGELOG] is NVARCHAR(255), which means there's plenty of space for e.g. GUID? #LiquibaseHelp

$
0
0
is it possible for
Liquibase update command to auto-generate changeset Id's e.g. when they're omitted / left blank?
The ID field in [DATABASECHANGELOG] is NVARCHAR(255), which means there's plenty of space for e.g. GUID?
the reason for this: incremental IDs don't work very well in big teams with feature branching strategy. We want to ensure merge to master branch is as simple as possible.
what does everyone else use for IDs to guarantee uniqueness?

Re : is it possible for @liquibase to auto-generate changeset Id's? The ID field in [DATABASECHANGELOG] is NVARCHAR(255), which means there's plenty of space for e.g. GUID? #LiquibaseHelp

$
0
0
Can you share your changelog and how you are executing Liquibase? I tried creating an XML changelog with no id field on any of the changesets and run the update command from the console and got what I expected to see - an error:

Unexpected error running Liquibase: cvc-complex-type.4: Attribute 'id' must appear on element 'changeSet'.

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

Re : What's the proper way to conditionallly create a view?

Empty db.changelog.yml

$
0
0
Hi

Currently i have an PostgreSQL database, i have added liquibase 3.8.2 to dynamically add new tables or new fields in existing table. That's Ok when in my tests i add include
But if i remove my tests yaml file is empty and Liquibase don't like it ?
Could i have an empty liquibase file in first step ?

Regards

Re : Empty db.changelog.yml

$
0
0
It sounds like you are on the right track. If you have an existing database and want to start using Liquibase to manage changes, then using the generateChangeLog command to create the initial changelog file is correct, and then the changeLogSync command will mark the database as being managed by Liquibase and in-sync with the changelog you just generated. You can then create new databases with the correct structure using the update command. To make future changes, you add to the changelog file and then run the update command to deploy those changes to the different databases you are managing. 

The page https://www.liquibase.org/documentation/existing_project.html goes into more detail.

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

same configuration file for Liquibase Maven Plugin and Spring Boot yaml

$
0
0
Hi

Currently i have two configuration files, one propertie file for liquibase maven plugin and another yaml file for my SpringBoot application
Do you have an idea or solution to have only One configuration file ?
Regards

Re : same configuration file for Liquibase Maven Plugin and Spring Boot yaml

$
0
0
I don't think there is an option with the current version of the liquibase plugin to have it get configured from a Spring Boot yaml file. I don't know enough about Spring Boot to know whether it can be configured using a properties file. So if we assume that the software is unlikely to change to accomdate that request, your best bet would be to write a simple script around one or the other to translate the configuration into the needed format. 

For example, you could decide that the Spring Boot yaml file is the "one true source" for configuration, and then write a script that converts from the yaml format to a properties file for use by maven.

We do something like that here at Datical for test configuration - we have a single file that is actually a groovy data structure, and then we have a couple of scripts to convert that to either a properties file for our Java based integration tests or to a ruby file for our Ruby-based end-to-end tests. 

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

Copy database schema created by liquibase into another database by java code

$
0
0
Hi,

I have a database A created using liquibase changeset. Now, it's possible to create another database B and to initialize that database similar to database A schema.

How can that be achieve using liquibase? Basically I want to clone database A into database B, with the same databasechangelogs entries because the database can be updated in real time.

Thanks,
czetsuya

Re : Copy database schema created by liquibase into another database by java code

$
0
0
I saw your question on StackOverflow as well. As the commenters said, it isn't clear exactly what you are trying to do here. If you have database A and database B, it seems to me you would just run liquibase update command pointing to A, and then run it again pointing to B. 

I guess the biggest misunderstanding I have is that 'm not sure what you mean by "the database can be updated in real time" - do you mean that there is some other process that is affecting database A that is not Liquibase? 

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

Re : Copy database schema created by liquibase into another database by java code

$
0
0
Hi Steve,

Sorry for the confusion I may have cause.

Let me try to explain the workflow:

  1. We initialize a new database a schema using liquibase changeset.
  2. We can add a new table and field to database a at run-time. Or during the time when the application is running. For example, we add a new table people to the schema of database a, which is not originally in the changeset.
  3. Now, we create a new database b.
  4. We want to import the schema of database a to b, with people table.
I hope that is clear.

Thanks and Regards,
czetsuya

Re : Copy database schema created by liquibase into another database by java code

$
0
0
OK, I understand. If I was an architect on your project I would suggest that could be a bad design decision, but there is obviously I don't know about your application and why you are doing that. 

Assuming you are committed to that, then here are a couple of ways you might solve it. 

1. Use the same 'real time schema modification' step you use on A to also modify B. 
2. Use the Liquibase diffChangeLog functionality to compare database A to database B and create a changelog that only has the changes between A and B, then use Liquibase update to apply the changes to B. With this technique you would need to embed Liquibase in your application (if you haven't already done that) and then add some methods to your code to call Liquibase. 

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

Re : Copy database schema created by liquibase into another database by java code

$
0
0
Hi Steve,

Indeed, I don't really agree with the design myself but there is a logic for doing so and this is one way of achieving the requirement given the technology and framework we have.

Thanks for the suggestions. I was actually able to solve the issue by exporting a liquibase changelog and executing it to the new data source.

Best Regards,
czetsuya

Re : Copy database schema created by liquibase into another database by java code

$
0
0
Excellent. Glad to hear you got this working.

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

Diff primary key index creation loop (spring boot + Hibernate 5)

$
0
0

When I generate the first diff. The diff file looks correct. It has the tables that we need to create. I run the app, it creates the tables (Oracle), all is good. For validation purposes I run the diff command again, expecting for it to return with no changes. Unfortunately it comes back with changes to the Primary Key Column. If I run the new set of changes and do another diff. It still comes back with the same change logs. It will do this infinitely.

I think that I might be using the wrong decencies but I am very lost.

POM

<parent>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-parent</artifactId>
   <version>2.2.1.RELEASE</version>
   <relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
   <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
   </dependency>
   <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
   </dependency>
   <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <optional>true</optional>
   </dependency>
   <dependency>
      <groupId>com.oracle.database</groupId>
      <artifactId>ojdbc7</artifactId>
      <version>12.1.0.1</version>
   </dependency>
   <dependency>
      <groupId>org.liquibase</groupId>
      <artifactId>liquibase-core</artifactId>
   </dependency>
</dependencies>
...
<plugin>
    <groupId>org.liquibase</groupId>
    <artifactId>liquibase-maven-plugin</artifactId>
    <version>3.8.1</version>
    <configuration>
        <propertyFile>/src/main/resources/liquibase.properties</propertyFile>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>org.liquibase.ext</groupId>
            <artifactId>liquibase-hibernate5</artifactId>
            <version>3.6</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <version>2.2.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>2.0.1.Final</version>
        </dependency>
    </dependencies>
</plugin>

Diff that is always created

databaseChangeLog:
- changeSet:
    id: 1578435590163-1
    author: Stackoverflow (generated)
    changes:
    - dropPrimaryKey:
        tableName: users
- changeSet:
    id: 1578435590163-2
    author: Stackoverflow (generated)
    changes:
    - createIndex:
        columns:
        - column:
            name: username
        indexName: IX_usersPK
        tableName: users
        unique: true
- changeSet:
    id: 1578435590163-3
    author: Stackoverflow (generated)
    changes:
    - addPrimaryKey:
        columnNames: username
        constraintName: usersPK
        forIndexName: IX_usersPK
        tableName: users

liquibase properties

referenceUrl=hibernate:spring:com.example?dialect=org.hibernate.dialect.Oracle12cDialect&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy

Re : loadData + CSV + computedValue

$
0
0
Hi,

value[XXX] is not used for loadData / column at the moment. I've implemented the defaultValue[XXX] handling which could be used in your case once it will be merged.
  1. add the column to the CSV without data
  2. Define your query in defaultValueComputed
Regards,
  Gyula

Is there any solution for DB entity dependency handling

$
0
0
Hi,

Some DB entities have dependencies. e.g a view / stored procedure depends on views / tables it uses. Is there a way to handle it with xml changelog?

In my scenario ViewB uses ViewA. To change ViewA steps required:
  1. ViewB needs to be dropped.
  2. ViewA needs to be changed
  3. ViewB needs to be recreated

I have the following changesets:

<changeSet id="Create ViewA" runOnChange="true" ...>
      <createView viewName="ViewA" replaceIfExists="true" .../></changeSet>

<changeSet id="Create ViewB" runOnChange="true" ...>
      <createView viewName="ViewB" remarks="Uses ViewA" .../></changeSet>

The only solution I've found to drop and recreate all the views all the time, but that's far from ideal.
  • dropView throws an error if the view does not exists so that needs to be in a separate changeSet with precondition
Some ideas:
  • dropView should have an option 'ifExists' avoiding error if the view does not exists
  • dropView could have an option to drop all dependent objects. (The dependency can be retrieved from the DB.)
  • Some way to call or ask another changeSet to be executed later. In that case if a dependent view (ViewA) has been changed. The changeset drops the depending view(s) (ViewB) and ask liquibase to execute the changesets recreating it. This feature could be used in many other cases. liquibase only needs to change the flag if a changeSet needs to be executed.
  • Similar: changeSet could have a 'dependsOn' option listing the changesets it depends on. If the depended changeset was executed, execute this also even if not changed
  • precondition similar to changeSetExecuted (or just a option)  to check if a changeSet was executed in the current execution.
Thanks,
    Gyula Bibernáth

Re : loadData + CSV + computedValue

Viewing all 1169 articles
Browse latest View live


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