diff --git a/src/main/antlr4/com/zendesk/maxwell/schema/ddl/mysql.g4 b/src/main/antlr4/com/zendesk/maxwell/schema/ddl/mysql.g4 index 15c1b43b7..f25f4791b 100644 --- a/src/main/antlr4/com/zendesk/maxwell/schema/ddl/mysql.g4 +++ b/src/main/antlr4/com/zendesk/maxwell/schema/ddl/mysql.g4 @@ -14,11 +14,8 @@ statement: | BEGIN ; - - - create_database: - CREATE DATABASE if_not_exists? name (default_character_set | default_collate)*; + CREATE (DATABASE | SCHEMA) if_not_exists? name (default_character_set | default_collate)*; create_table: create_table_preamble diff --git a/src/test/java/com/zendesk/maxwell/schema/ddl/DDLParserTest.java b/src/test/java/com/zendesk/maxwell/schema/ddl/DDLParserTest.java index 18b53417c..d9e8a4958 100644 --- a/src/test/java/com/zendesk/maxwell/schema/ddl/DDLParserTest.java +++ b/src/test/java/com/zendesk/maxwell/schema/ddl/DDLParserTest.java @@ -360,6 +360,13 @@ public void testCreateDatabase() { assertThat(create.encoding, is("latin1")); } + @Test + public void testCreateSchema() { + List changes = parse("CREATE SCHEMA if not exists `foo`"); + DatabaseCreate create = (DatabaseCreate) changes.get(0); + assertThat(create.dbName, is("foo")); + } + @Test public void testCommentSyntax() { List changes = parse("CREATE DATABASE if not exists `foo` default character set='latin1' /* generate by server */");