diff --git a/content/en/docs/reference/compatibility/mysql-compatibility.md b/content/en/docs/reference/compatibility/mysql-compatibility.md index 6515f38a9..1e2b780c8 100644 --- a/content/en/docs/reference/compatibility/mysql-compatibility.md +++ b/content/en/docs/reference/compatibility/mysql-compatibility.md @@ -149,3 +149,23 @@ USE `mykeyspace:-80@rdonly` ``` A similar effect can be achieved by using a database name like `mykeyspace:-80@rdonly` in your MySQL application client connection string. + +### Create/Drop Database + +Vitess does not support CREATE and DROP DATABASE queries out of the box. + +But, to make it possible to provision databases, a plugin mechanism exists. +The plugin has to take care of creating and dropping the database, and update the topology & VSchema so that Vitess can start receiving queries for the new keyspace. + +The plugin should implement the `DBDDLPlugin` interface, and be saved into a new file in the `go/vt/vtgate/engine/` directory. + +```go +type DBDDLPlugin interface { + CreateDatabase(ctx context.Context, name string) error + DropDatabase(ctx context.Context, name string) error +} +``` + +It must then register itself calling `DBDDLRegister`. +You can take a look at the `dbddl_plugin.go` in the engine package for an example of how it's done. +Finally, you need to add a command line flag to vtgate to have it use the new plugin: `-dbddl_plugin=myPluginName`