database-migration change username or datasource

classic Classic list List threaded Threaded
11 messages Options
hug
Reply | Threaded
Open this post in threaded view
|

database-migration change username or datasource

hug
We use the database-migration plugin. It works perfekt.

Is ther a way to change the user (username/password), because the application database user don't have the rights to make structural changes in database (alter table).

Example:
The grails app use the www_my_app user and the migration plugin use root.
Reply | Threaded
Open this post in threaded view
|

Re: database-migration change username or datasource

pledbrook
Administrator
> We use the database-migration plugin. It works perfekt.
>
> Is ther a way to change the user (username/password), because the
> application database user don't have the rights to make structural changes
> in database (alter table).
>
> Example:
> The grails app use the www_my_app user and the migration plugin use root.

Burt is the authority on this plugin, but I think you can achieve what
you want with either environments or external configuration files. For
example, you could add:

    environments {
        ...
        dbm {
            username = "..."
            password = "..."
        }
    }

and run the DBM commands with 'grails -Dgrails.env=dbm dbm-update'

Alternatively, you can use the 'grails.config.locations' setting in
Config.groovy to load an external file in which you can add the data
source information (it will have the same format as in
DataSource.groovy). The settings in the external file will override
those defined in DataSource.groovy.

Hope that helps,

Peter

--
Peter Ledbrook
Grails Advocate
SpringSource - A Division of VMware
hug
Reply | Threaded
Open this post in threaded view
|

Re: database-migration change username or datasource

hug
Thanks Peter!

But that doesn't help (or I can't see how).
We set
grails.plugin.databasemigration.updateOnStart=true

Actualy, the update script will be executed before bootstrap. At this moment I would like to use an other database connection. Afterward the application should use the connection definied in DataSource.groovy.

Any ideas?

Stefan
Reply | Threaded
Open this post in threaded view
|

Re: database-migration change username or datasource

pledbrook
Administrator
> We set
> grails.plugin.databasemigration.updateOnStart=true
>
> Actualy, the update script will be executed before bootstrap. At this moment
> I would like to use an other database connection. Afterward the application
> should use the connection definied in DataSource.groovy.

I can't see how to do this. I'm pretty sure the Database Migration
plugin uses the existing dataSource object to connect to the database.
If you want to configure a different dataSource for the
'updateOnStart', then you will probably have to raise a feature
request.

Peter

--
Peter Ledbrook
Grails Advocate
SpringSource - A Division of VMware
Reply | Threaded
Open this post in threaded view
|

Re: database-migration change username or datasource

Burt Beckwith
Administrator
Right, the commandline scripts use the DataSource associated with the executing environment, so 'grails dbm-update' runs in the dev environment, 'grails prod dbm-update' runs in prod, 'grails -Dgrails.env=UAT dbm-update' runs in the custom 'UAT' environment, etc. Auto-start runs similarly runs using whatever environment the war is configured with (most likely prod).

For now I'd create a custom environment in DataSource.groovy with the connect info that allows table modifications and run migrations from the commandline with dbm-update using that environment just before deploying the new war.

Raise an enhancement request at http://jira.grails.org/browse/GPDATABASEMIGRATION

Burt

> > We set
> > grails.plugin.databasemigration.updateOnStart=true
> >
> > Actualy, the update script will be executed before bootstrap. At this moment
> > I would like to use an other database connection. Afterward the application
> > should use the connection definied in DataSource.groovy.
>
> I can't see how to do this. I'm pretty sure the Database Migration
> plugin uses the existing dataSource object to connect to the database.
> If you want to configure a different dataSource for the
> 'updateOnStart', then you will probably have to raise a feature
> request.
>
> Peter
>
>
Reply | Threaded
Open this post in threaded view
|

Re: database-migration change username or datasource

pledbrook
Administrator
> For now I'd create a custom environment in DataSource.groovy with the
> connect info that allows table modifications and run migrations from the
> commandline with dbm-update using that environment just before deploying the
> new war.

Unfortunately this doesn't work with something like CloudFoundry :)
I've also realised that if you're deploying to CloudFoundry, you don't
have much chance to execute the changelog-sync command to indicate
that the database is already at a certain point. It might make sense
to have a 'sync()' that can be called from BootStrap in those
circumstances.

Peter

--
Peter Ledbrook
Grails Advocate
SpringSource - A Division of VMware
hug
Reply | Threaded
Open this post in threaded view
|

Re: database-migration change username or datasource

hug
Thanks for the answers. I'll raise an enhancement request.
hug
Reply | Threaded
Open this post in threaded view
|

Re: database-migration change username or datasource

hug
Reply | Threaded
Open this post in threaded view
|

Re: database-migration change username or datasource

Burt Beckwith
Administrator
No need to vote, it'll get fixed :)

Burt
 
> Please vote for http://jira.grails.org/browse/GPDATABASEMIGRATION-41
>
> _______________________________________________
> If you reply to this email, your message will be added to the discussion below:
> http://grails-plugins.847840.n3.nabble.com/database-migration-change-username-or-datasource-tp3258032p3261954.html
> To start a new topic under Grails Plugins, email [hidden email]
> To unsubscribe from Grails Plugins, visit
Reply | Threaded
Open this post in threaded view
|

Re: database-migration change username or datasource

gustav
Is this fixed already? Or when will this be fixed?
sed
Reply | Threaded
Open this post in threaded view
|

Re: database-migration change username or datasource

sed
In reply to this post by Burt Beckwith
Are there any news about this problem? I can't find the solution mentioned.
Our provider has prohibited to connect from app to database using dbo_ user. But to change database structure we must connect using dbo_ user doing the changes. If there are no changes to do, we would like to connect using www_ user.
So, normal case is connecting using dbo_ and doing the changes, after that connecting using www_ user to work with web-app.
Maybe at startup of webserver there are no db changes so there is no need to connect using dbo_ user - we could directly using www_ user. This could be a possilbe solution...
Is there any solution on the horizon?
Reading your post we should be able to use this for 2 years now ;)

Br, Thomas