I have it working very similar as you describe, so I think it can help you, but instead with a UUID
, in my case it is with a Date
, any way, the same case.
In my changelog, I have a property to calculate current date:
<property name="now" value="CURRENT_DATE" dbms="hsqldb" />
Then, I have a user table which is created with this changeSet:
<changeSet author="miguel" id="1448735850226-1">
<createTable tableName="usuario">
<column name="login" type="VARCHAR(255)">
<constraints nullable="false"/>
</column>
<column name="oid" type="VARCHAR(255)"/>
<column name="fecha" type="date" defaultValueComputed="${now}">
<constraints nullable="false"/>
</column>
<column name="nombre" type="VARCHAR(255)"/>
<column name="apellidos" type="VARCHAR(255)"/>
<column name="activo" type="BOOLEAN"/>
</createTable>
</changeSet>
As you can see, fecha
column is not null and it has defaultValueComputed
attribute to ${now}
function.
I have a users.csv
file that create test users (usuarios-test.csv
):
login;oid;nombre;apellidos;activo
user;b776052e-7c9f-11e5-8584-67d602646e6f;Prueba;Prueba;true
As you can see, in the csv file I use headers line and I don't include fecha
field. (In my case, UUID
are pre-generated, but I could change it as you are).
Finally I have this loadData
change
<changeSet author="miguel" id="1448735850226-16">
<loadData tableName="usuario" encoding="UTF-8"
file="src/main/resources/liquibase/changelogs/usuarios-test.csv"
quotchar="'" separator=";" >
<column header="login" name="login" type="STRING"/>
<column header="oid" name="oid" type="STRING"/>
<column header="nombre" name="nombre" type="STRING"/>
<column header="apellidos" name="apellidos" type="STRING"/>
<column header="activo" name="activo" type="BOOLEAN"/>
</loadData>
</changeSet>
As you can see, I declared all columns present into .csv
file and fecha
is not included, so defaultValueComputed
works and I get users created with current date.
Hope it helps!