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

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

There is a newer version: 0.10
Show newest version
package org.leberrigaud.maven.plugins.database

final class Oracle implements Database
{
    boolean sysdba

    String driverClass()
    {
        'oracle.jdbc.OracleDriver'
    }

    String defaultPort()
    {
        '1521'
    }

    String defaultSid()
    {
        'orcl'
    }

    boolean supportsSchema()
    {
        true
    }

    String defaultRootUsername()
    {
        'sys'
    }

    String adminDbName()
    {
        ''
    }

    String url(DatabaseConfiguration config)
    {
        "jdbc:oracle:thin:@$config.host:${config.getPort(defaultPort())}:${config.sid ?: defaultSid()}"
    }

    List create(DatabaseConfiguration config)
    {
        def sql = []
        if (config.databaseSchema) sql.addAll([
                "CREATE USER $config.databaseSchema IDENTIFIED BY ${config.databaseSchema}_pwd DEFAULT TABLESPACE USERS QUOTA UNLIMITED ON USERS"
        ])
        sql.addAll([
                "CREATE USER $config.username IDENTIFIED BY $config.password DEFAULT TABLESPACE USERS QUOTA UNLIMITED ON USERS",
                "GRANT ALL PRIVILEGES TO $config.username WITH ADMIN OPTION",
                "GRANT CONNECT TO $config.username",
        ])
        sql
    }

    List update(DatabaseConfiguration config)
    {
        []
    }

    List drop(DatabaseConfiguration config)
    {
        def sql = []
        if (config.databaseSchema) sql.add("DROP USER $config.databaseSchema CASCADE")
        sql.add("DROP USER $config.username CASCADE")
        sql
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy