How can I generate id for primary key autoincrement column when populating table with Liquibase? With my current configuration Liquibase is putting NULL
into ID column.
My changelog file:
<?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.2.xsd">
<property name="now" value="now()" dbms="mysql,h2"/>
<property name="now" value="current_timestamp" dbms="postgresql"/>
<!--
Added the entity Skill.
-->
<changeSet id="20141029084149" author="jhipster">
<createTable tableName="T_SKILL">
<column name="id" type="bigint">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="value" type="varchar(255)"/>
<column name="description" type="varchar(255)"/>
</createTable>
<loadData encoding="UTF-8"
file="config/liquibase/skills.csv"
separator="|"
tableName="T_SKILL"/>
</changeSet>
</databaseChangeLog>
and skills.csv
file:
value|description
java|Java
java-ee|Java Enterprise Edition
junit|JUnit
You need to include autoIncrement="true" in the createTable column tag
<changeSet id="20141029084149" author="jhipster">
<createTable tableName="T_SKILL">
<column name="id" type="bigint" autoIncrement="true">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="value" type="varchar(255)"/>
<column name="description" type="varchar(255)"/>
</createTable>
</changeSet>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With