I try to load some data from csv file to the DB.
<changeSet id="Load data from CSV file Service" author="apal" >
<loadData tableName="service" file="liquibase/data/services.csv" >
<column name="id" header="id" />
<column name="fk_category_id" header="category_id"/>
<column name="name" header="name" />
<column name="search_terms" header="search_terms" />
</loadData>
</changeSet>
<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.4.xsd">
<changeSet id="create_service" author="apal">
<createTable tableName="service">
<column name="id" type="bigint" autoIncrement="true">
<constraints primaryKey="true"/>
</column>
<column name="name" type="varchar(255)"/>
<column name="fk_category_id" type="bigint"/>
<column name="search_terms" type="text"/>
</createTable>
</changeSet>
<changeSet id="adding_constraints_company_service_mapping" author="apal">
<addForeignKeyConstraint baseTableName="service" baseColumnNames="fk_category_id"
constraintName="fk_category_id"
referencedTableName="category"
referencedColumnNames="id"
onDelete="CASCADE"
onUpdate="RESTRICT"/>
</changeSet>
</databaseChangeLog>
Files CSV file It finds the file because i get this error:
Caused by: liquibase.exception.MigrationFailedException: Migration failed for changeset liquibase/data/data.xml::Load data from CSV file Service::apal: Reason: liquibase.exception.DatabaseException: The file liquibase/data/számlakezelés Könyvelő Könyvelő szolgáltatás Könyvelői szolgáltatások Professzionális könyvelő Vállalkozás könyvelése Adótanácsadás Pénzügyi szakember Üzleti könyvelés Könyvelési tanácsadás Könyvelői szolgáltatások CECCAR SAGA PFA könyvelés SRL könyvelés TVA was not found in the configured search path: - Spring classpath More locations can be added with the 'searchPath' parameter.
In the error message after 'The file liquibase/data/'... is data from the first row , fourth column. Any ideas ? Ty.
It is a known error of liquibase:
Here is the jira tiquet. As it is specified on the ticket you can solve it by adding type=string
to your column.
While adding an explicit column type definition as defined in original stackoverflow post
<column name="description" type="string" />
does the trick - for me it effectively requires to update already applied changesets which ideally I'd try to avoid.