Mysql Unique constraint issue and liquibase 3.0 when table name is "status" -
i have table named status :
| field | type | null | key | default | | +----------+------------------+------+-----+---------+----------------+ | id | int(11) unsigned | no | pri | null | auto_increment | | db_table | varchar(255) | no | | | | | name | varchar(255) | no | | | | | rank | varchar(6) | yes | | null | | | style_id | int(11) unsigned | no | | null | | +----------+------------------+------+-----+---------+----------------+
with create statement
create table `status` ( `id` int(11) unsigned not null auto_increment, `db_table` varchar(255) not null default '', `name` varchar(255) not null default '', `rank` varchar(6) default null, `style_id` int(11) unsigned not null, primary key (`id`) ) engine=myisam auto_increment=8 default charset=utf8
luqibase generatechangelog command
liquibase --url=jdbc:mysql://localhost/testdb generatechangelog
output
liquibase generatechangelog failed: error executing sql select constraint_name information_schema.table_constraints constraint_schema='testdb' , constraint_type='unique' , table_name='status': unknown table 'status' in information_schema
i have no clue why issue , add more puzzle response mysql
select * information_schema.table_constraints constraint_schema='testdb' , table_name='status';
error 1109 (42s02): unknown table 'status' in information_schema`
although, see without condition table_name='status'
status listed
what wrong mysql and/or liquibase ? "status" reserved thing or special purpose cannot use table name .
the same schema works fine older liquibase version 2.0.5 :(
edit
this issue has sth table name status
case a
drop table status; create table statusx ( id int(11) unsigned auto_increment, name varchar(20) , primary key (`id`) );
liquibase --url=jdbc:mysql://localhost/testdb generatechangelog
works fine
case b
drop table statusx; create table status ( id int(11) unsigned auto_increment, name varchar(20), primary key (`id`) ); liquibase --url=jdbc:mysql://localhost/testdb generatechangelog
same error:
liquibase generatechangelog failed: error executing sql select constraint_name information_schema.table_constraints constraint_schema='testdb' , constraint_type='unique' , table_name='status': unknown table 'status' in information_schema
direct query fails:
select * information_schema.table_constraints constraint_schema = 'testdb' , table_name='status';
while works:
select * information_schema.table_constraints constraint_schema='testdb' , table_name='statusx';
works
select * information_schema.table_constraints constraint_schema='ufg_a' , table_name='`status`';
i think fix liquibase use backticks around table names e.g table_name='status
'
something strange mysql, hope status not reserved word in mysql
Comments
Post a Comment