All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.leberrigaud.maven.plugins.database.MySql.groovy Maven / Gradle / Ivy

There is a newer version: 0.10
Show newest version
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