|
3 | 3 | import liquibase.database.Database;
|
4 | 4 | import liquibase.exception.DatabaseException;
|
5 | 5 | import liquibase.ext.hibernate.database.HibernateDatabase;
|
6 |
| -import liquibase.logging.LogFactory; |
7 |
| -import liquibase.logging.LogService; |
8 |
| -import liquibase.logging.Logger; |
9 | 6 | import liquibase.snapshot.DatabaseSnapshot;
|
10 | 7 | import liquibase.snapshot.InvalidExampleException;
|
11 | 8 | import liquibase.snapshot.SnapshotGenerator;
|
12 | 9 | import liquibase.snapshot.SnapshotGeneratorChain;
|
13 | 10 | import liquibase.structure.DatabaseObject;
|
| 11 | +import liquibase.structure.core.Schema; |
| 12 | +import org.hibernate.boot.model.relational.Namespace; |
14 | 13 | import org.hibernate.boot.spi.MetadataImplementor;
|
15 | 14 | import org.hibernate.mapping.Table;
|
16 | 15 |
|
@@ -107,4 +106,27 @@ protected org.hibernate.mapping.Table findHibernateTable(DatabaseObject example,
|
107 | 106 | }
|
108 | 107 | return null;
|
109 | 108 | }
|
| 109 | + |
| 110 | + protected static boolean schemaMatchesTable( |
| 111 | + DatabaseObject example, |
| 112 | + Table hibernateTable |
| 113 | + ) { |
| 114 | + if (example.getSchema().getName() != null && example.getSchema().getName().equalsIgnoreCase(hibernateTable.getSchema())) { |
| 115 | + return true; |
| 116 | + } |
| 117 | + |
| 118 | + return example.getSchema().isDefault() && hibernateTable.getSchema() == null; |
| 119 | + } |
| 120 | + |
| 121 | + protected static boolean schemaMatchesNamespace( |
| 122 | + Schema schema, |
| 123 | + Namespace hibernateNamespace |
| 124 | + ) { |
| 125 | + if (hibernateNamespace.getName().getSchema() != null && hibernateNamespace.getName().getSchema().matches(schema.getName())) { |
| 126 | + return true; |
| 127 | + } |
| 128 | + |
| 129 | + return hibernateNamespace.getName().getSchema() == null && schema.isDefault(); |
| 130 | + } |
| 131 | + |
110 | 132 | }
|
0 commit comments