0
votes

I am trying to insert a value into mysql using a liquibase script:

<changeSet author="liquibase" id="6225">
    <insert tableName="master">
        <column name="id" value="7"/>
        <column name="insightname" value="topic_modelling"/>
        <column name="insighttype" value="1" valueBoolean="true"/>
    </insert>
</changeSet>

But when I try this it gives me the error:

Error: Data truncation: Data too long for column 'insighttype' at row 1 [Failed SQL: INSERT INTO db.master (id, insightname, insighttype) VALUES ('7', 'topic_modelling', '1')]

Is it because the value are passed with quotes? What is the solution?

My Create table statement looks like:

CREATE TABLE ss_insightmaster (
  id int(11) NOT NULL AUTO_INCREMENT,
  insightname varchar(255) NOT NULL,
  enabled tinyint(1) DEFAULT NULL,
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
1
can you include SHOW CREATE TABLE db.master to be sure we're understanding the types right?danblack
@danblack - added CREATE TABLE statement.Tom J Muthirenthi

1 Answers

2
votes

Every Database handles Boolean values differently - Liquibase is expecting the insighttype of type BIT not TINYINT since you are using MySQL as you can see in the liquibase github.

OR

As a dirty hack you can run the changeset with another dbms where a NUMBERis expected:

<changeSet author="liquibase" id="6225" dbms="oracle">
    <insert tableName="master">
        <column name="id" value="7"/>
        <column name="insightname" value="topic_modelling"/>
        <column name="insighttype" value="1" valueBoolean="true"/>
    </insert>
</changeSet>