Hello Emeric,

You should definitely not be using a manual sql command to change data in the Galaxy database, since there are many dependencies between various database objects.  For example, users have roles, permissions, histories, histories have datasets, etc.  Making a change manually to a row in the galaxy_user table will not properly handle any of these dependencies, and in fact, could possible create data inconsistencies which could cause significant issues.

The script in ~/scripts/cleanup_datasets/cleanup_dataset.py should be executed regularly ( we advice configuring cron to run it daily ).  It will handle cleaning up everything you need, keeping the data in the database consistent.  Note the various command line options that can be used for the script.  Here are our crontab entries for this in our production environment:

33 12 * * * /bin/sh /galaxy/home/g2main/galaxy_main/run_cleanup.sh

and here is the run_cleanup.sh script:

#!/bin/sh

# necessary to get our local python
PATH=/opt/local/bin:/usr/postgres/8.3/bin/64:/galaxy/home/g2main/solaris2.10-amd64/bin:/usr/bin:
export PATH

cd `dirname $0`

bash ./scripts/cleanup_datasets/delete_datasets_main.sh
bash ./scripts/cleanup_datasets/delete_userless_histories_main.sh
bash ./scripts/cleanup_datasets/purge_histories_main.sh
bash ./scripts/cleanup_datasets/purge_datasets_main.sh 

In order to purge a user, you'll need to be a Galaxy admin, and you'll need to uncomment the following lines in ~/lib/galaxy/controller/admin.py ( lines 88-92 in change set 3409:a8b176655f0b ).

    #TODO: enhance to account for trans.app.config.allow_user_deletion here so that we can eliminate these operations if 
    # the setting is False
    #operations.append( grids.GridOperation( "Delete", condition=( lambda item: not item.deleted ), allow_multiple=True ) )
    #operations.append( grids.GridOperation( "Undelete", condition=( lambda item: item.deleted and not item.purged ), allow_multiple=True ) )
    #operations.append( grids.GridOperation( "Purge", condition=( lambda item: item.deleted and not item.purged ), allow_multiple=True ) )

The Delete / Undelete and Purge buttons will then be displayed on the Manage users page in the Admin view.  Purging a user does not delete a row from the galaxy_user table, but simple marks the user as purged, among other things.  here are teh comments in the purge_user() methid of the admin controller:

        # This method should only be called for a User that has previously been deleted.
        # We keep the User in the database ( marked as purged ), and stuff associated
        # with the user's private role in case we want the ability to unpurge the user 
        # some time in the future.
        # Purging a deleted User deletes all of the following:
        # - History where user_id = User.id
        #    - HistoryDatasetAssociation where history_id = History.id
        #    - Dataset where HistoryDatasetAssociation.dataset_id = Dataset.id
        # - UserGroupAssociation where user_id == User.id
        # - UserRoleAssociation where user_id == User.id EXCEPT FOR THE PRIVATE ROLE
        # Purging Histories and Datasets must be handled via the cleanup_datasets.py script

The cleanup_datasets script will handle all dataset file deletions from disk based on the number of days you want the file on disk after it's associated row has been marked deleted in the database.

Greg


On Feb 18, 2010, at 8:30 AM, Emeric Dubois wrote:

Hello,

I have installed Galaxy in a production environment for multiple users.
My installation of Galaxy has been configured such that only users who are logged in may use it and only admin may create a new user.
I have a problem, I can create but can't delete a account...
For the moment, I use a mysql command to block account :

UPDATE galaxy.galaxy_user SET deleted = 1 WHERE galaxy_user.email LIKE "emeric.dubois@gmail.com" ;


By this command, the account is inactive but all data associated are in database and in dataset folder.
To free disk space, a set of scripts exist to remove the data files (histories and deleted datasets) but I haven't found a script to delete a user and all his data in database and dataset folder.
Can you tell me if you have a solution to cleanly delete a user and his data ?

Thank you.

Best regards

Emeric


--
*****************************************

Emeric Dubois
Plateforme MGX
Institut de Génomique Fonctionnelle
UMR 5203 CNRS – U 661 INSERM – Universite de Montpellier
141 rue de la cardonille
34094 Montpellier Cedex 05, France
Tel: 04 67 14 29 32

Emeric.Dubois@igf.cnrs.fr

*****************************************


--
Ce message a été vérifié par MailScanner
pour des virus ou des polluriels et rien de
suspect n'a été trouvé.

_______________________________________________
galaxy-dev mailing list
galaxy-dev@lists.bx.psu.edu
http://lists.bx.psu.edu/listinfo/galaxy-dev


Greg Von Kuster
Galaxy Development Team
greg@bx.psu.edu