Skip to content

Commit

Permalink
Merge pull request #723 from vitessio/hg-dbddl-plugin
Browse files Browse the repository at this point in the history
create and drop database plugin documentation
  • Loading branch information
harshit-gangal authored Mar 12, 2021
2 parents 816539d + 4ce0655 commit f5196df
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions content/en/docs/reference/compatibility/mysql-compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

0 comments on commit f5196df

Please sign in to comment.