Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entity attribute Schema does not work for diff #248

Open
chernikov321 opened this issue May 31, 2020 · 9 comments
Open

Entity attribute Schema does not work for diff #248

chernikov321 opened this issue May 31, 2020 · 9 comments

Comments

@chernikov321
Copy link

chernikov321 commented May 31, 2020

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

@hkakutalua
Copy link

Any update on this?

@hkakutalua
Copy link

Can i contribute with a PR?

@DejfCold
Copy link

DejfCold commented 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

@sitole
Copy link

sitole commented 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? ❤️

@sitole
Copy link

sitole commented Jul 7, 2022

Hey, any update in this topic? 🚀
We are ready to somehow support fix, because its critical use-case for our codebase with many database tables.

Its any possibility to support Liquidbase? ❤️

@kataggart
Copy link

@sitole I will see if we can give this some love and attention...

@sitole
Copy link

sitole commented Aug 18, 2022

@kataggart
Hi! I would like to ask if there has been any progress? 🚀
I see there is some issue (liquibase/liquibase#3174) about schemes in Maven plugin but iam not sure if its relevant or not.

Thanks for your reply ✨

@kataggart
Copy link

@sitole wish I had a timeline for you, but I do not; we should hopefully be able to take a look at this soon.

@dehidehidehi
Copy link

Hello, I have the same issue, hoping this gets some love!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Open Issues
Development

No branches or pull requests

8 participants