db-changelog-1.9.0.xml 4.95 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
  ~ #%L
  ~ SUMARiS
  ~ %%
  ~ Copyright (C) 2019 SUMARiS Consortium
  ~ %%
  ~ This program is free software: you can redistribute it and/or modify
  ~ it under the terms of the GNU General Public License as
  ~ published by the Free Software Foundation, either version 3 of the
  ~ License, or (at your option) any later version.
  ~
  ~ This program is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  ~ GNU General Public License for more details.
  ~
  ~ You should have received a copy of the GNU General Public
  ~ License along with this program.  If not, see
  ~ <http://www.gnu.org/licenses/gpl-3.0.html>.
  ~ #L%
  -->

<databaseChangeLog
	xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd"
	logicalFilePath="https://github.com/sumaris-net/sumaris-pod/blob/master/sumaris-core/src/main/resources/net/sumaris/core/db/changelog/hsqldb/db-changelog-1.9.0.xml">

	<property name="sqlCheck.not_empty.sql" value="SELECT COUNT(*) FROM STATUS WHERE ID=1"/>
	<property name="sqlCheck.not_empty.expectedResult" value="1"/>

  <!-- table BATCH -->
	<changeSet author="ludovic.pecquot@e-is.pro" id="1625816880596-1">
		<preConditions onFail="MARK_RAN">
			<not>
				<columnExists tableName="BATCH" columnName="SUBGROUP_COUNT"/>
			</not>
		</preConditions>
		<addColumn tableName="BATCH">
			<column name="SUBGROUP_COUNT" type="INTEGER"/>
		</addColumn>
	</changeSet>

	<!-- table EXPECTED_SALE -->
	<changeSet author="ludovic.pecquot@e-is.pro" id="1625816880596-2">
		<preConditions onFail="MARK_RAN">
			<not>
				<tableExists tableName="EXPECTED_SALE"/>
			</not>
		</preConditions>
		<createTable tableName="EXPECTED_SALE">
			<column name="ID" type="INT">
				<constraints primaryKey="true"/>
			</column>
			<column name="SALE_DATE" type="TIMESTAMP"/>
			<column name="SALE_LOCATION_FK" type="INT">
				<constraints nullable="false" referencedTableName="LOCATION" foreignKeyName="EXPECTED_SALE_SALE_LOCATION_FKC"/>
			</column>
			<column name="SALE_TYPE_FK" type="INT">
				<constraints nullable="false" referencedTableName="SALE_TYPE" foreignKeyName="EXPECTED_SALE_SALE_TYPE_FKC"/>
			</column>
			<column name="TRIP_FK" type="INT">
				<constraints referencedTableName="TRIP" foreignKeyName="EXPECTED_SALE_TRIP_FKC"/>
			</column>
			<column name="LANDING_FK" type="INT">
				<constraints referencedTableName="LANDING" foreignKeyName="EXPECTED_SALE_LANDING_FKC"/>
			</column>
		</createTable>
		<!-- sequence created in all/db-changelog-1.9.0.xml -->
	</changeSet>

	<!-- table SALE_MEASUREMENT -->
	<changeSet author="ludovic.pecquot@e-is.pro" id="1625816880596-3">
		<preConditions onFail="MARK_RAN">
			<not>
				<columnExists tableName="SALE_MEASUREMENT" columnName="EXPECTED_SALE_FK"/>
			</not>
		</preConditions>
		<addColumn tableName="SALE_MEASUREMENT">
			<column name="EXPECTED_SALE_FK" type="INT">
				<constraints referencedTableName="EXPECTED_SALE" foreignKeyName="SALE_MEASUREMENT_EXPECTED_SALE_FKC"/>
			</column>
		</addColumn>
		<dropNotNullConstraint tableName="SALE_MEASUREMENT" columnName="SALE_FK"/>
	</changeSet>

	<!-- table PRODUCT -->
	<changeSet author="ludovic.pecquot@e-is.pro" id="1625816880596-4">
		<preConditions onFail="MARK_RAN">
			<not>
				<columnExists tableName="PRODUCT" columnName="EXPECTED_SALE_FK"/>
			</not>
		</preConditions>
		<addColumn tableName="PRODUCT">
			<column name="EXPECTED_SALE_FK" type="INT">
				<constraints referencedTableName="EXPECTED_SALE" foreignKeyName="PRODUCT_EXPECTED_SALE_FKC"/>
			</column>
		</addColumn>
	</changeSet>

102
103
104
105
106
107
108
109
110
111
	<!-- table LANDING: remove RANK_ORDER_ON_VESSEL if empty -->
	<changeSet author="ludovic.pecquot@e-is.pro" id="1625816880596-5">
		<preConditions onFail="MARK_RAN">
			<sqlCheck expectedResult="0">select count(*) from LANDING where RANK_ORDER_ON_VESSEL is not null</sqlCheck>
		</preConditions>
		<dropColumn tableName="LANDING">
			<column name="RANK_ORDER_ON_VESSEL"/>
		</dropColumn>
	</changeSet>

112
113
114
115
116
117
118
119
120
121
122
123

	<!-- update SYSTEM_VERSION -->
	<changeSet author="benoit.lavenier@e-is.pro" id="1625816880596-200" runOnChange="true">
		<delete tableName="SYSTEM_VERSION">
			<where>LABEL='1.9.0'</where>
		</delete>
		<insert tableName="SYSTEM_VERSION">
			<column name="ID" valueComputed="NEXT VALUE FOR SYSTEM_VERSION_SEQ"/>
			<column name="LABEL">1.9.0</column>
			<column name="DESCRIPTION">
				- BATCH: Add column SUBGROUP_COUNT
        - Add table EXPECTED_SALE and add relations on SALE_MEASUREMENT and PRODUCT
124
				- Drop column LANDING.RANK_ORDER_ON_VESSEL
125
126
127
128
129
130
131
132
			</column>
			<column name="CREATION_DATE" valueComputed="sysdate"/>
			<column name="UPDATE_DATE" valueComputed="current_timestamp"/>
			<column name="COMMENTS">
			</column>
		</insert>
	</changeSet>
</databaseChangeLog>