002-finance-status.xml
1.93 KB
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
<?xml version="1.0" encoding="UTF-8"?>
<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
https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.27.xsd">
<!--
pbc-finance v0.17 — add lifecycle status to journal entries.
Adds a `status` column tracking the lifecycle of each journal
entry (POSTED → SETTLED on shipment/receipt, POSTED → REVERSED
on cancellation). The default value 'POSTED' covers any rows
that already exist on an upgraded environment, where they were
all created from confirm events.
See JournalEntryStatus.kt for the semantics of each value and
why status is a separate axis from JournalEntryType.
New CHECK constraint mirrors the enum to keep DBA-side hand-
edits from drifting from the application's expectations.
-->
<changeSet id="finance-status-001" author="vibe_erp">
<comment>Add status column with POSTED default + CHECK + index</comment>
<sql>
ALTER TABLE finance__journal_entry
ADD COLUMN status varchar(16) NOT NULL DEFAULT 'POSTED';
ALTER TABLE finance__journal_entry
ADD CONSTRAINT finance__journal_entry_status_check
CHECK (status IN ('POSTED', 'SETTLED', 'REVERSED'));
CREATE INDEX finance__journal_entry_status_idx
ON finance__journal_entry (status);
</sql>
<rollback>
DROP INDEX finance__journal_entry_status_idx;
ALTER TABLE finance__journal_entry
DROP CONSTRAINT finance__journal_entry_status_check;
ALTER TABLE finance__journal_entry
DROP COLUMN status;
</rollback>
</changeSet>
</databaseChangeLog>