org.leberrigaud.maven.plugins.database.MySql.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of database-maven-plugin Show documentation
Show all versions of database-maven-plugin Show documentation
A maven plugin to create and drop databases and their associated users.
package org.leberrigaud.maven.plugins.database
final class MySql implements Database
{
String driverClass()
{
'com.mysql.jdbc.Driver'
}
String defaultPort()
{
'3306'
}
boolean supportsSchema()
{
false
}
String defaultRootUsername()
{
'root'
}
String adminDbName()
{
'mysql'
}
String url(DatabaseConfiguration config)
{
"jdbc:mysql://$config.host:${config.getPort(defaultPort())}/${config.databaseName}?autoReconnect=true"
}
List create(DatabaseConfiguration config)
{
[
"create user '$config.username'@'localhost' identified by '$config.password'",
"create database $config.databaseName",
"grant all on ${config.databaseName}.* to '$config.username'@'localhost';"
]
}
List update(DatabaseConfiguration config)
{
[]
}
List drop(DatabaseConfiguration config)
{
[
"drop database $config.databaseName",
"drop user '$config.username'@'localhost'"
]
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy