PageRenderTime 40ms CodeModel.GetById 14ms app.highlight 23ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/galaxy/model/migrate/versions/0001_initial_tables.py

https://bitbucket.org/cistrome/cistrome-harvard/
Python | 213 lines | 182 code | 25 blank | 6 comment | 0 complexity | 6c5a85ed0c36a643c84894676d0b1839 MD5 | raw file
  1from sqlalchemy import *
  2from migrate import *
  3
  4import datetime
  5now = datetime.datetime.utcnow
  6
  7# Need our custom types, but don't import anything else from model
  8from galaxy.model.custom_types import *
  9
 10import logging
 11log = logging.getLogger( __name__ )
 12
 13metadata = MetaData()
 14
 15# Tables as of changeset 1464:c7acaa1bb88f
 16User_table = Table( "galaxy_user", metadata,
 17    Column( "id", Integer, primary_key=True),
 18    Column( "create_time", DateTime, default=now ),
 19    Column( "update_time", DateTime, default=now, onupdate=now ),
 20    Column( "email", TrimmedString( 255 ), nullable=False ),
 21    Column( "password", TrimmedString( 40 ), nullable=False ),
 22    Column( "external", Boolean, default=False ) )
 23
 24History_table = Table( "history", metadata,
 25    Column( "id", Integer, primary_key=True),
 26    Column( "create_time", DateTime, default=now ),
 27    Column( "update_time", DateTime, index=True, default=now, onupdate=now ),
 28    Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True ),
 29    Column( "name", TrimmedString( 255 ) ),
 30    Column( "hid_counter", Integer, default=1 ),
 31    Column( "deleted", Boolean, index=True, default=False ),
 32    Column( "purged", Boolean, index=True, default=False ),
 33    Column( "genome_build", TrimmedString( 40 ) ) )
 34
 35HistoryDatasetAssociation_table = Table( "history_dataset_association", metadata,
 36    Column( "id", Integer, primary_key=True ),
 37    Column( "history_id", Integer, ForeignKey( "history.id" ), index=True ),
 38    Column( "dataset_id", Integer, ForeignKey( "dataset.id" ), index=True ),
 39    Column( "create_time", DateTime, default=now ),
 40    Column( "update_time", DateTime, default=now, onupdate=now ),
 41    Column( "copied_from_history_dataset_association_id", Integer, ForeignKey( "history_dataset_association.id" ), nullable=True ),
 42    Column( "hid", Integer ),
 43    Column( "name", TrimmedString( 255 ) ),
 44    Column( "info", TrimmedString( 255 ) ),
 45    Column( "blurb", TrimmedString( 255 ) ),
 46    Column( "peek" , TEXT ),
 47    Column( "extension", TrimmedString( 64 ) ),
 48    Column( "metadata", MetadataType(), key="_metadata" ),
 49    Column( "parent_id", Integer, ForeignKey( "history_dataset_association.id" ), nullable=True ),
 50    Column( "designation", TrimmedString( 255 ) ),
 51    Column( "deleted", Boolean, index=True, default=False ),
 52    Column( "visible", Boolean ) )
 53
 54Dataset_table = Table( "dataset", metadata,
 55    Column( "id", Integer, primary_key=True ),
 56    Column( "create_time", DateTime, default=now ),
 57    Column( "update_time", DateTime, index=True, default=now, onupdate=now ),
 58    Column( "state", TrimmedString( 64 ) ),
 59    Column( "deleted", Boolean, index=True, default=False ),
 60    Column( "purged", Boolean, index=True, default=False ),
 61    Column( "purgable", Boolean, default=True ),
 62    Column( "external_filename" , TEXT ),
 63    Column( "_extra_files_path", TEXT ),
 64    Column( 'file_size', Numeric( 15, 0 ) ) )
 65
 66ImplicitlyConvertedDatasetAssociation_table = Table( "implicitly_converted_dataset_association", metadata,
 67    Column( "id", Integer, primary_key=True ),
 68    Column( "create_time", DateTime, default=now ),
 69    Column( "update_time", DateTime, default=now, onupdate=now ),
 70    Column( "hda_id", Integer, ForeignKey( "history_dataset_association.id" ), index=True, nullable=True ),
 71    Column( "hda_parent_id", Integer, ForeignKey( "history_dataset_association.id" ), index=True ),
 72    Column( "deleted", Boolean, index=True, default=False ),
 73    Column( "metadata_safe", Boolean, index=True, default=True ),
 74    Column( "type", TrimmedString( 255 ) ) )
 75
 76ValidationError_table = Table( "validation_error", metadata,
 77    Column( "id", Integer, primary_key=True ),
 78    Column( "dataset_id", Integer, ForeignKey( "history_dataset_association.id" ), index=True ),
 79    Column( "message", TrimmedString( 255 ) ),
 80    Column( "err_type", TrimmedString( 64 ) ),
 81    Column( "attributes", TEXT ) )
 82
 83Job_table = Table( "job", metadata,
 84    Column( "id", Integer, primary_key=True ),
 85    Column( "create_time", DateTime, default=now ),
 86    Column( "update_time", DateTime, default=now, onupdate=now ),
 87    Column( "history_id", Integer, ForeignKey( "history.id" ), index=True ),
 88    Column( "tool_id", String( 255 ) ),
 89    Column( "tool_version", TEXT, default="1.0.0" ),
 90    Column( "state", String( 64 ) ),
 91    Column( "info", TrimmedString( 255 ) ),
 92    Column( "command_line", TEXT ),
 93    Column( "param_filename", String( 1024 ) ),
 94    Column( "runner_name", String( 255 ) ),
 95    Column( "stdout", TEXT ),
 96    Column( "stderr", TEXT ),
 97    Column( "traceback", TEXT ),
 98    Column( "session_id", Integer, ForeignKey( "galaxy_session.id" ), index=True, nullable=True ),
 99    Column( "job_runner_name", String( 255 ) ),
100    Column( "job_runner_external_id", String( 255 ) ) )
101
102JobParameter_table = Table( "job_parameter", metadata,
103    Column( "id", Integer, primary_key=True ),
104    Column( "job_id", Integer, ForeignKey( "job.id" ), index=True ),
105    Column( "name", String(255) ),
106    Column( "value", TEXT ) )
107
108JobToInputDatasetAssociation_table = Table( "job_to_input_dataset", metadata,
109    Column( "id", Integer, primary_key=True ),
110    Column( "job_id", Integer, ForeignKey( "job.id" ), index=True ),
111    Column( "dataset_id", Integer, ForeignKey( "history_dataset_association.id" ), index=True ),
112    Column( "name", String(255) ) )
113
114JobToOutputDatasetAssociation_table = Table( "job_to_output_dataset", metadata,
115    Column( "id", Integer, primary_key=True ),
116    Column( "job_id", Integer, ForeignKey( "job.id" ), index=True ),
117    Column( "dataset_id", Integer, ForeignKey( "history_dataset_association.id" ), index=True ),
118    Column( "name", String(255) ) )
119
120Event_table = Table( "event", metadata,
121    Column( "id", Integer, primary_key=True ),
122    Column( "create_time", DateTime, default=now ),
123    Column( "update_time", DateTime, default=now, onupdate=now ),
124    Column( "history_id", Integer, ForeignKey( "history.id" ), index=True, nullable=True ),
125    Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True, nullable=True ),
126    Column( "message", TrimmedString( 1024 ) ),
127    Column( "session_id", Integer, ForeignKey( "galaxy_session.id" ), index=True, nullable=True ),
128    Column( "tool_id", String( 255 ) ) )
129
130GalaxySession_table = Table( "galaxy_session", metadata,
131    Column( "id", Integer, primary_key=True ),
132    Column( "create_time", DateTime, default=now ),
133    Column( "update_time", DateTime, default=now, onupdate=now ),
134    Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True, nullable=True ),
135    Column( "remote_host", String( 255 ) ),
136    Column( "remote_addr", String( 255 ) ),
137    Column( "referer", TEXT ),
138    Column( "current_history_id", Integer, ForeignKey( "history.id" ), nullable=True ),
139    Column( "session_key", TrimmedString( 255 ), index=True, unique=True ),
140    Column( "is_valid", Boolean, default=False ),
141    Column( "prev_session_id", Integer )
142    )
143
144GalaxySessionToHistoryAssociation_table = Table( "galaxy_session_to_history", metadata,
145    Column( "id", Integer, primary_key=True ),
146    Column( "create_time", DateTime, default=now ),
147    Column( "session_id", Integer, ForeignKey( "galaxy_session.id" ), index=True ),
148    Column( "history_id", Integer, ForeignKey( "history.id" ), index=True ) )
149
150StoredWorkflow_table = Table( "stored_workflow", metadata,
151    Column( "id", Integer, primary_key=True ),
152    Column( "create_time", DateTime, default=now ),
153    Column( "update_time", DateTime, default=now, onupdate=now ),
154    Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True, nullable=False ),
155    Column( "latest_workflow_id", Integer,
156            ForeignKey( "workflow.id", use_alter=True, name='stored_workflow_latest_workflow_id_fk' ), index=True ),
157    Column( "name", TEXT ),
158    Column( "deleted", Boolean, default=False ),
159    )
160
161Workflow_table = Table( "workflow", metadata,
162    Column( "id", Integer, primary_key=True ),
163    Column( "create_time", DateTime, default=now ),
164    Column( "update_time", DateTime, default=now, onupdate=now ),
165    Column( "stored_workflow_id", Integer, ForeignKey( "stored_workflow.id" ), index=True, nullable=False ),
166    Column( "name", TEXT ),
167    Column( "has_cycles", Boolean ),
168    Column( "has_errors", Boolean )
169    )
170
171WorkflowStep_table = Table( "workflow_step", metadata,
172    Column( "id", Integer, primary_key=True ),
173    Column( "create_time", DateTime, default=now ),
174    Column( "update_time", DateTime, default=now, onupdate=now ),
175    Column( "workflow_id", Integer, ForeignKey( "workflow.id" ), index=True, nullable=False ),
176    Column( "type", String(64) ),
177    Column( "tool_id", TEXT ),
178    Column( "tool_version", TEXT ),
179    Column( "tool_inputs", JSONType ),
180    Column( "tool_errors", JSONType ),
181    Column( "position", JSONType ),
182    Column( "config", JSONType ),
183    Column( "order_index", Integer )
184    )
185
186WorkflowStepConnection_table = Table( "workflow_step_connection", metadata,
187    Column( "id", Integer, primary_key=True ),
188    Column( "output_step_id", Integer, ForeignKey( "workflow_step.id" ), index=True ),
189    Column( "input_step_id", Integer, ForeignKey( "workflow_step.id" ), index=True ),
190    Column( "output_name", TEXT ),
191    Column( "input_name", TEXT)
192    )
193
194StoredWorkflowUserShareAssociation_table = Table( "stored_workflow_user_share_connection", metadata,
195    Column( "id", Integer, primary_key=True ),
196    Column( "stored_workflow_id", Integer, ForeignKey( "stored_workflow.id" ), index=True ),
197    Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True )
198    )
199
200StoredWorkflowMenuEntry_table = Table( "stored_workflow_menu_entry", metadata,
201    Column( "id", Integer, primary_key=True ),
202    Column( "stored_workflow_id", Integer, ForeignKey( "stored_workflow.id" ), index=True ),
203    Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True ),
204    Column( "order_index", Integer ) )
205
206def upgrade(migrate_engine):
207    metadata.bind = migrate_engine
208    metadata.create_all()
209
210## def downgrade(migrate_engine):
211##    metadata.bind = migrate_engine
212##     # Operations to reverse the above upgrade go here.
213##     pass