MySql
Testing
To test against MySQL docker test container set the platform to mysql
in
src/test/resources/application-test.yaml
Refer to docs / testing if application-test.yaml doesn't exist yet.
Collation
With MySql can (and probably should) specify the collation and character set we want the
database to use. In the example below we specify the collation as utf8mb4_unicode_ci
.
ebean:
test:
platform: mysql #, h2, postgres, mysql, oracle, sqlserver
ddlMode: dropCreate # none | dropCreate | migrations | create
dbName: test
mysql:
collation: utf8mb4_unicode_ci
characterSet: utf8mb4
The above will use the following defaults:
username: | {databaseName} |
---|---|
password: | test |
port: | 4306 |
url: | jdbc:mysql://localhost:{port}/{databaseName} |
driver: | com.mysql.jdbc.Driver |
image: | mysql:{version} |
"default" - Collation
We can specify the collation to be default
and with that the collection will be left up
to the default that MySql would use.
ebean:
test:
platform: mysql #, h2, postgres, mysql, oracle, sqlserver
ddlMode: dropCreate # none | dropCreate | migrations | create
dbName: test
mysql:
version: 8.0
collation: default
In the logs with logging DEBUG level for io.ebean.docker
we can see:
--character-set-server
and --collation-server
... INFO io.ebean.docker.commands.Commands - Run container ut_mysql with port:4306 db:my_app user:my_app mode:Create shutdown:
... DEBUG io.ebean.docker.commands.Commands - docker run -d --name ut_mysql -p 4306:3306 -e MYSQL_ROOT_PASSWORD=admin mysql:5.6
Types
UUID
UUID is not a native MySQL type and can be mapped to either BINARY(16) or VARCHAR(36).
JSON
We can use @DbJson
to map content.
History support
History support for MySQL is provided by generating triggers and history table.