Am having a go at deploying Jmix with Docker.
Is there any way, or a guide to explain, how to create e.g. custom database views when the database is created by docker-compose?
I used to use init scripts with Cuba. Not sure what to do with Jmix…
Actually I figured it out (first real play with Jmix )
For others (and my future reference):
In SRC --> main --> resources --> [package] ... --> liquibase --> changelog
Create new file
e.g.
020-init-SALES_BY_WEEK-view.xml
<?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
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
<changeSet id="create-sales-by-month-view" author="mimi" context="!cuba">
<preConditions>
<tableExists tableName="sale"/>
</preConditions>
<createView viewName="SALES_BY_WEEK">
with t as (select generate_series((now() - interval '12 week' + interval '1 week'), now(), '1 week')::date _date)
select gen_random_uuid() as id, date_trunc('week', _date)::Date as _date, coalesce(sum(amount),0) as total_sales from t
left join sale on date_trunc('week', sale.date_)::date = date_trunc('week', t._date)::date
group by t._date
order by _date ASC
</createView>
</changeSet>
</databaseChangeLog>
Done!
1 Like
You can also create new Liquibase changelogs right from the Data Store context menu: