Skip to content

Commit a0f836b

Browse files
committed
- create schema with liquibase
1 parent 8a686ef commit a0f836b

File tree

3 files changed

+38
-15
lines changed

3 files changed

+38
-15
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<databaseChangeLog
4+
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
7+
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
8+
9+
<changeSet id="1" author="hhimanshu">
10+
<createTable tableName="books"
11+
remarks="A table to contain all books">
12+
<column name="id" type="int">
13+
<constraints nullable="false" unique="true" primaryKey="true"/>
14+
</column>
15+
<column name="name" type="varchar(255)">
16+
<constraints nullable="false" unique="true"/>
17+
</column>
18+
<column name="author" type="int">
19+
<constraints nullable="false"/>
20+
</column>
21+
</createTable>
22+
23+
<createTable tableName="authors"
24+
remarks="A table to contain all the authors">
25+
<column name="id" type="int">
26+
<constraints nullable="false" primaryKey="true"/>
27+
</column>
28+
<column name="name" type="varchar(100)">
29+
<constraints nullable="false"/>
30+
</column>
31+
</createTable>
32+
33+
<addForeignKeyConstraint baseTableName="books" baseColumnNames="author"
34+
constraintName="author_fk"
35+
referencedTableName="authors" referencedColumnNames="id"/>
36+
</changeSet>
37+
</databaseChangeLog>

src/main/resources/db/changelog/01-create-books-schema.xml

-14
This file was deleted.

src/main/resources/db/liquibase-changelog.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
77
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
88

9-
<include file="changelog/01-create-books-schema.xml" relativeToChangelogFile="true"/>
9+
<include file="changelog/01-create-books-and-author-schema.xml" relativeToChangelogFile="true"/>
1010
</databaseChangeLog>

0 commit comments

Comments
 (0)