question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Entity attribute Schema does not work for diff

See original GitHub issue

For example, i have two entities:

package ru.atc.initsqldata.entity.multischema;

import javax.persistence.*;

@Entity
@Table(schema = "schema1", name = "table1")
public class Entity1 {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private String name;
}

and

package ru.atc.initsqldata.entity.multischema;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(schema = "schema2", name = "table2")
public class Entity2 {

    @Id
    private Long id;

    private String name;
}

When i run liquibase:diff script, i have the changelog like:

databaseChangeLog:
- changeSet:
    id: 1590958915435-1
    author: chernikov (generated)
    changes:
    - createTable:
        columns:
        - column:
            autoIncrement: true
            constraints:
              primaryKey: true
              primaryKeyName: table1PK
            name: id
            type: BIGINT
        - column:
            name: name
            type: VARCHAR(255)
        tableName: table1
- changeSet:
    id: 1590958915435-2
    author: chernikov (generated)
    changes:
    - createTable:
        columns:
        - column:
            constraints:
              nullable: false
            name: id
            type: BIGINT
        - column:
            name: name
            type: VARCHAR(255)
        tableName: table2
- changeSet:
    id: 1590958915435-3
    author: chernikov (generated)
    changes:
    - addPrimaryKey:
        columnNames: id
        constraintName: table2PK
        tableName: table2

Is it possible to get changelog like this? … tableName: table1 schemaName: schema1 … tableName: table2 schemaName: schema2

Here is my configs: pom.xml

          <plugin>
                <groupId>org.liquibase</groupId>
                <artifactId>liquibase-maven-plugin</artifactId>
                <version>3.5.5</version>
                <configuration>
                    <propertyFile>
                        ${project.build.outputDirectory}/properties/application-${liquibase.profile}.properties
                    </propertyFile>
                    <logging>info</logging>
                </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.1.5.RELEASE</version>
                    </dependency>
                    <dependency>
                        <groupId>javax.validation</groupId>
                        <artifactId>validation-api</artifactId>
                        <version>2.0.1.Final</version>
                    </dependency>
                    <dependency>
                        <groupId>org.javassist</groupId>
                        <artifactId>javassist</artifactId>
                        <version>3.24.0-GA</version>
                    </dependency>
                    <dependency>
                        <groupId>org.yaml</groupId>
                        <artifactId>snakeyaml</artifactId>
                        <version>1.12</version>
                    </dependency>
                </dependencies>
            </plugin>

and properties file:

driver=org.postgresql.Driver
url=jdbc:postgresql://localhost:5432/test_db
username=test_db
password=pas
changeLogFile=@project.basedir@/src/main/resources/liquibase/changelog-master.yaml
referenceUrl=hibernate:spring:ru.atc.initsqldata.entity.multischema?dialect=org.hibernate.dialect.PostgreSQLDialect
diffChangeLogFile=@project.basedir@/src/main/resources/liquibase/changelog-@timestamp@.yaml
ignoreClasspathPrefix=true
changelogSchemaName=liquibase

┆Issue is synchronized with this Jira Bug by Unito

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:8

github_iconTop GitHub Comments

4reactions
DejfColdcommented, Jun 7, 2022

Same issue here 2 years later. diffChangeLog --schemas=public,other --includeSchema=true generates schemaName="HIBERNATE" tableName="table1" and schemaName="HIBERNATE" tableName="table2" for entities defined as @Table(name = "table1", schema = "public") and @Table(name = "table2", schema = "other" respectively.

Versions:

  • org.liquidbase.gradle:2.1.1
  • org.liquibase:liquibase-core:4.10.0
  • org.liquibase.ext:liquibase-hibernate5:4.10.0
  • org.springframework.boot:2.5.4

seems like (also) unresolved #160 could be related

3reactions
sitolecommented, Jun 7, 2022

Same issue, its not possible to generate diff with tables in different Postgres Scheme. Liquibase is trying to generate all tables in default scheme from zero everytime.

Some quickfix? ❤️

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I handle different data types in an Entity-Attribute ...
using a varchar2 datatype to represent all data types in a known format. Numbers and chars are no problem, date values can be...
Read more >
How can database entities and attributes be different?
Entity and Attributes are two essential terms of a database management system (DBMS). The main difference between the Entity and attribute is that...
Read more >
Entity-attribute-value (EAV) design in PostgreSQL – don't do it!
This article explains what the entity-attribute-value (EAV) model is and why you shouldn't use it in a relational database.
Read more >
How to model an entity type that can have different sets of ...
Not shared but, from memory, I can tell that at least three attributes are present in all Categories. 4. Is there a chance...
Read more >
Exploring Performance Issues for a Clinical Database ... - NCBI
Background: The entity-attribute-value representation with classes and relationships (EAV/CR) provides a flexible and simple database schema to store ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found