Skip to content

Commit e81c74d

Browse files
authored
Merge pull request #18028 from bhaskar16/BAEL-8226
[BAEL-8226] changelog for liquibase
2 parents fa9b892 + 32c1104 commit e81c74d

File tree

4 files changed

+172
-0
lines changed

4 files changed

+172
-0
lines changed

persistence-modules/liquibase/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@
6868
<plugin>
6969
<groupId>org.apache.maven.plugins</groupId>
7070
<artifactId>maven-compiler-plugin</artifactId>
71+
<configuration>
72+
<source>9</source>
73+
<target>9</target>
74+
</configuration>
7175
</plugin>
7276
</plugins>
7377
</build>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.baeldung.liquibase.entity;
2+
3+
import java.sql.Timestamp;
4+
5+
import jakarta.persistence.Entity;
6+
import jakarta.persistence.Id;
7+
import jakarta.persistence.Table;
8+
9+
@Entity
10+
@Table(name = "authors")
11+
public class Author {
12+
@Id
13+
private Long id;
14+
private String name;
15+
private Timestamp created_at;
16+
17+
public Long getId() {
18+
return id;
19+
}
20+
21+
public void setId(Long id) {
22+
this.id = id;
23+
}
24+
25+
public String getName() {
26+
return name;
27+
}
28+
29+
public void setName(String name) {
30+
this.name = name;
31+
}
32+
33+
public Timestamp getCreated_at() {
34+
return created_at;
35+
}
36+
37+
public void setCreated_at(Timestamp created_at) {
38+
this.created_at = created_at;
39+
}
40+
}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
package com.baeldung.liquibase.utility;
2+
3+
import java.util.List;
4+
5+
import liquibase.database.AbstractJdbcDatabase;
6+
import liquibase.database.Database;
7+
import liquibase.database.core.DB2Database;
8+
import liquibase.database.core.DerbyDatabase;
9+
import liquibase.database.core.FirebirdDatabase;
10+
import liquibase.database.core.H2Database;
11+
import liquibase.database.core.HsqlDatabase;
12+
import liquibase.database.core.InformixDatabase;
13+
import liquibase.database.core.MSSQLDatabase;
14+
import liquibase.database.core.MySQLDatabase;
15+
import liquibase.database.core.OracleDatabase;
16+
import liquibase.database.core.PostgresDatabase;
17+
import liquibase.database.core.SQLiteDatabase;
18+
import liquibase.database.core.SybaseASADatabase;
19+
import liquibase.database.core.SybaseDatabase;
20+
import liquibase.database.core.UnsupportedDatabase;
21+
import liquibase.datatype.LiquibaseDataType;
22+
import liquibase.datatype.core.BigIntType;
23+
import liquibase.datatype.core.BlobType;
24+
import liquibase.datatype.core.BooleanType;
25+
import liquibase.datatype.core.CharType;
26+
import liquibase.datatype.core.ClobType;
27+
import liquibase.datatype.core.CurrencyType;
28+
import liquibase.datatype.core.DateTimeType;
29+
import liquibase.datatype.core.DateType;
30+
import liquibase.datatype.core.DecimalType;
31+
import liquibase.datatype.core.DoubleType;
32+
import liquibase.datatype.core.FloatType;
33+
import liquibase.datatype.core.IntType;
34+
import liquibase.datatype.core.MediumIntType;
35+
import liquibase.datatype.core.NCharType;
36+
import liquibase.datatype.core.NVarcharType;
37+
import liquibase.datatype.core.NumberType;
38+
import liquibase.datatype.core.TimeType;
39+
import liquibase.datatype.core.TimestampType;
40+
import liquibase.datatype.core.TinyIntType;
41+
import liquibase.datatype.core.UUIDType;
42+
import liquibase.datatype.core.VarcharType;
43+
44+
public class LiquibaseDatatypes {
45+
public static void main(String[] args) {
46+
List<LiquibaseDataType> dataTypes = getDataTypes();
47+
List<AbstractJdbcDatabase> databases = getDatabases();
48+
49+
for (LiquibaseDataType dataTypeInstance : dataTypes) {
50+
try {
51+
LiquibaseDataType dataType = dataTypeInstance;
52+
dataType.finishInitialization("");
53+
System.out.println(dataType.getName());
54+
55+
for (AbstractJdbcDatabase databaseInstance : databases) {
56+
try {
57+
Database database = databaseInstance;
58+
String databaseType = dataType.toDatabaseDataType(database)
59+
.toString();
60+
System.out.println(databaseInstance.getName() + ": " + databaseType);
61+
} catch (Exception e) {
62+
System.err.println("Error initializing database class " + databaseInstance.getName() + ": " + e.getMessage());
63+
}
64+
}
65+
System.out.println();
66+
} catch (Exception e) {
67+
System.err.println("Error initializing data type class " + dataTypeInstance.getName() + ": " + e.getMessage());
68+
}
69+
}
70+
}
71+
72+
private static List<LiquibaseDataType> getDataTypes() {
73+
return List.of(
74+
new BooleanType(),
75+
new TinyIntType(),
76+
new IntType(),
77+
new MediumIntType(),
78+
new BigIntType(),
79+
new FloatType(),
80+
new DoubleType(),
81+
new DecimalType(),
82+
new NumberType(),
83+
new BlobType(),
84+
new DateTimeType(),
85+
new TimeType(),
86+
new TimestampType(),
87+
new DateType(),
88+
new CharType(),
89+
new VarcharType(),
90+
new NCharType(),
91+
new NVarcharType(),
92+
new ClobType(),
93+
new CurrencyType(),
94+
new UUIDType());
95+
}
96+
97+
private static List<AbstractJdbcDatabase> getDatabases() {
98+
return List.of(
99+
new MySQLDatabase(),
100+
new SQLiteDatabase(),
101+
new H2Database(),
102+
new PostgresDatabase(),
103+
new DB2Database(),
104+
new MSSQLDatabase(),
105+
new OracleDatabase(),
106+
new HsqlDatabase(),
107+
new FirebirdDatabase(),
108+
new DerbyDatabase(),
109+
new InformixDatabase(),
110+
new SybaseDatabase(),
111+
new SybaseASADatabase());
112+
}
113+
}
114+

persistence-modules/liquibase/src/main/resources/liquibase/changelog.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,18 @@
1414
</column>
1515
</createTable>
1616
</changeSet>
17+
18+
<changeSet id="2" author="unknown">
19+
<createTable tableName="authors">
20+
<column name="id" type="bigint">
21+
<constraints primaryKey="true" nullable="false"/>
22+
</column>
23+
<column name="name" type="varchar">
24+
<constraints nullable="false"/>
25+
</column>
26+
<column name="created_at" type="timestamp">
27+
<constraints nullable="false"/>
28+
</column>
29+
</createTable>
30+
</changeSet>
1731
</databaseChangeLog>

0 commit comments

Comments
 (0)