[hg] galaxy 2357: Add new migration script that creates missing ...
details: http://www.bx.psu.edu/hg/galaxy/rev/5a0100a94b12 changeset: 2357:5a0100a94b12 user: Greg Von Kuster <greg@bx.psu.edu> date: Tue Apr 21 10:26:58 2009 -0400 description: Add new migration script that creates missing indexes and default data on galaxy_user and history_dataset_association tables. Fix the change datatype display in the edit_attributes template. Fix the tool config for main. 4 file(s) affected in this change: lib/galaxy/model/migrate/versions/0004_indexes_and_defaults.py manage_db.sh templates/dataset/edit_attributes.mako tool_conf.xml.main diffs (191 lines): diff -r db86a8c5e9b0 -r 5a0100a94b12 lib/galaxy/model/migrate/versions/0004_indexes_and_defaults.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/galaxy/model/migrate/versions/0004_indexes_and_defaults.py Tue Apr 21 10:26:58 2009 -0400 @@ -0,0 +1,61 @@ +from sqlalchemy import * +from sqlalchemy.orm import * +from migrate import * +import sys, logging + +log = logging.getLogger( __name__ ) +log.setLevel(logging.DEBUG) +handler = logging.StreamHandler( sys.stdout ) +format = "%(name)s %(levelname)s %(asctime)s %(message)s" +formatter = logging.Formatter( format ) +handler.setFormatter( formatter ) +log.addHandler( handler ) + +metadata = MetaData( migrate_engine ) +db_session = scoped_session( sessionmaker( bind=migrate_engine, autoflush=False, transactional=False ) ) +User_table = Table( "galaxy_user", metadata, autoload=True ) +HistoryDatasetAssociation_table = Table( "history_dataset_association", metadata, autoload=True ) + +def boolean_false(): + if migrate_engine.name == 'postgres' or migrate_engine.name == 'mysql': + return False + elif migrate_engine.name == 'sqlite': + return 0 + else: + raise Exception( 'Unable to convert data for unknown database type: %s' % db ) + +def upgrade(): + # Load existing tables + metadata.reflect() + # Add 2 indexes to the galaxy_user table + i = Index( 'ix_galaxy_user_deleted', User_table.c.deleted ) + try: + i.create() + except Exception, e: + log.debug( "Adding index 'ix_galaxy_user_deleted' to galaxy_user table failed: %s" % ( str( e ) ) ) + i = Index( 'ix_galaxy_user_purged', User_table.c.purged ) + try: + i.create() + except Exception, e: + log.debug( "Adding index 'ix_galaxy_user_purged' to galaxy_user table failed: %s" % ( str( e ) ) ) + # Set the default data in the galaxy_user table, but only for null values + cmd = "UPDATE galaxy_user SET deleted = %s WHERE deleted is null" + cmd = cmd % boolean_false() + try: + db_session.execute( cmd ) + except Exception, e: + log.debug( "Setting default data for galaxy_user.deleted column failed: %s" % ( str( e ) ) ) + cmd = "UPDATE galaxy_user SET purged = %s WHERE purged is null" + cmd = cmd % boolean_false() + try: + db_session.execute( cmd ) + except Exception, e: + log.debug( "Setting default data for galaxy_user.purged column failed: %s" % ( str( e ) ) ) + # Add 1 index to the history_dataset_association table + i = Index( 'ix_hda_copied_from_library_dataset_dataset_association_id', HistoryDatasetAssociation_table.c.copied_from_library_dataset_dataset_association_id ) + try: + i.create() + except Exception, e: + log.debug( "Adding index 'ix_hda_copied_from_library_dataset_dataset_association_id' to history_dataset_association table failed: %s" % ( str( e ) ) ) +def downgrade(): + pass diff -r db86a8c5e9b0 -r 5a0100a94b12 manage_db.sh --- a/manage_db.sh Tue Apr 21 10:01:47 2009 -0400 +++ b/manage_db.sh Tue Apr 21 10:26:58 2009 -0400 @@ -1,4 +1,9 @@ #!/bin/sh + +####### +# NOTE: To downgrade to a specific version, use something like: +# sh manage_db.sh downgrade --version=3 +####### cd `dirname $0` python -ES ./scripts/manage_db.py $@ diff -r db86a8c5e9b0 -r 5a0100a94b12 templates/dataset/edit_attributes.mako --- a/templates/dataset/edit_attributes.mako Tue Apr 21 10:01:47 2009 -0400 +++ b/templates/dataset/edit_attributes.mako Tue Apr 21 10:26:58 2009 -0400 @@ -6,12 +6,11 @@ <%def name="datatype( dataset, datatypes )"> <select name="datatype"> - ## $datatypes.sort() %for ext in datatypes: %if dataset.ext == ext: - <option value="${ext}" selected="yes">${_(ext)}}</option> + <option value="${ext}" selected="yes">${_(ext)}</option> %else: - <option value="${ext}">${_(ext)}}</option> + <option value="${ext}">${_(ext)}</option> %endif %endfor </select> diff -r db86a8c5e9b0 -r 5a0100a94b12 tool_conf.xml.main --- a/tool_conf.xml.main Tue Apr 21 10:01:47 2009 -0400 +++ b/tool_conf.xml.main Tue Apr 21 10:26:58 2009 -0400 @@ -9,14 +9,6 @@ <tool file="data_source/flymine.xml" /> <tool file="data_source/encode_db.xml" /> <tool file="data_source/epigraph_import.xml" /> - </section> - <section name="Get ENCODE Data" id="encode"> - <tool file="data_source/encode_import_chromatin_and_chromosomes.xml"/> - <tool file="data_source/encode_import_genes_and_transcripts.xml"/> - <tool file="data_source/encode_import_multi-species_sequence_analysis.xml"/> - <tool file="data_source/encode_import_transcription_regulation.xml"/> - <tool file="data_source/encode_import_all_latest_datasets.xml" /> - <tool file="data_source/encode_import_gencode.xml" /> </section> <section name="Send Data" id="send"> <tool file="data_destination/epigraph.xml" /> @@ -42,17 +34,6 @@ <tool file="filters/headWrapper.xml" /> <tool file="filters/tailWrapper.xml" /> </section> - <section name="Filter and Sort" id="filter"> - <tool file="stats/filtering.xml" /> - <tool file="filters/sorter.xml" /> - <tool file="filters/grep.xml" /> - </section> - <section name="Join, Subtract and Group" id="group"> - <tool file="filters/joiner.xml" /> - <tool file="filters/compare.xml"/> - <tool file="new_operations/subtract_query.xml"/> - <tool file="stats/grouping.xml" /> - </section> <section name="Convert Formats" id="convert"> <tool file="filters/bed2gff.xml" /> <tool file="fasta_tools/fasta_to_tabular.xml" /> @@ -68,15 +49,21 @@ <tool file="fasta_tools/fasta_to_tabular.xml" /> <tool file="fasta_tools/tabular_to_fasta.xml" /> </section> + <section name="Filter and Sort" id="filter"> + <tool file="stats/filtering.xml" /> + <tool file="filters/sorter.xml" /> + <tool file="filters/grep.xml" /> + </section> + <section name="Join, Subtract and Group" id="group"> + <tool file="filters/joiner.xml" /> + <tool file="filters/compare.xml"/> + <tool file="new_operations/subtract_query.xml"/> + <tool file="stats/grouping.xml" /> + </section> <section name="Extract Features" id="features"> <tool file="filters/ucsc_gene_bed_to_exon_bed.xml" /> <tool file="extract/extract_GFF_Features.xml" /> </section> - <!-- - <section name="Pattern-Matching" id="patmat"> - <tool file="patmat/findcluster_mysql.xml" /> - </section> - --> <section name="Fetch Sequences" id="fetchSeq"> <tool file="extract/extract_genomic_dna.xml" /> </section> @@ -149,12 +136,19 @@ <tool file="hyphy/hyphy_nj_tree_wrapper.xml" /> <tool file="hyphy/hyphy_dnds_wrapper.xml" /> </section> - <section name="Taxonomy manipulation" id="tax_manipulation"> + <section name="Metagenomic analyses" id="tax_manipulation"> <tool file="taxonomy/gi2taxonomy.xml" /> <tool file="taxonomy/t2t_report.xml" /> <tool file="taxonomy/t2ps_wrapper.xml" /> <tool file="taxonomy/find_diag_hits.xml" /> + <tool file="taxonomy/lca.xml" /> <tool file="taxonomy/poisson2test.xml" /> + </section> + <section name="Short Read Analysis" id="short_read_analysis"> + <tool file="metag_tools/short_reads_figure_score.xml" /> + <tool file="metag_tools/short_reads_trim_seq.xml" /> + <tool file="metag_tools/megablast_wrapper.xml" /> + <tool file="metag_tools/megablast_xml_parser.xml" /> </section> <section name="EMBOSS" id="EMBOSSLite"> <tool file="emboss_5/emboss_antigenic.xml" /> @@ -265,10 +259,4 @@ <tool file="emboss_5/emboss_wordcount.xml" /> <tool file="emboss_5/emboss_wordmatch.xml" /> </section> - <section name="Short Read Analysis" id="short_read_analysis"> - <tool file="metag_tools/short_reads_figure_score.xml" /> - <tool file="metag_tools/short_reads_trim_seq.xml" /> - <tool file="metag_tools/megablast_wrapper.xml" /> - <tool file="metag_tools/megablast_xml_parser.xml" /> - </section> </toolbox>
participants (1)
-
Greg Von Kuster