mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-24 12:13:33 +08:00
Add migration to re-add the triggers
Make sure that any BEFORE/AFTER trigger is removed.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
"""
|
||||
Re-add triggers to update history.update_time when contents are changed.
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from sqlalchemy import MetaData
|
||||
|
||||
from galaxy.model.triggers import (
|
||||
drop_timestamp_triggers,
|
||||
install_timestamp_triggers,
|
||||
)
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
metadata = MetaData()
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
print(__doc__)
|
||||
metadata.bind = migrate_engine
|
||||
metadata.reflect()
|
||||
install_timestamp_triggers(migrate_engine)
|
||||
|
||||
|
||||
def downgrade(migrate_engine):
|
||||
metadata.bind = migrate_engine
|
||||
metadata.reflect()
|
||||
drop_timestamp_triggers(migrate_engine)
|
||||
@@ -71,7 +71,9 @@ def get_timestamp_install_sql(variant):
|
||||
|
||||
|
||||
def get_timestamp_drop_sql(variant):
|
||||
"""generate a list of statements to drop the timestammp update triggers"""
|
||||
"""
|
||||
Generate a list of statements to drop the timestamp update triggers
|
||||
"""
|
||||
|
||||
sql = []
|
||||
|
||||
@@ -79,8 +81,9 @@ def get_timestamp_drop_sql(variant):
|
||||
sql.append("DROP FUNCTION IF EXISTS update_history_update_time() CASCADE;")
|
||||
else:
|
||||
for operation in ['INSERT', 'UPDATE', 'DELETE']:
|
||||
sql.append(build_drop_trigger(operation, 'history_dataset_association'))
|
||||
sql.append(build_drop_trigger(operation, 'history_dataset_collection_association'))
|
||||
for when in ['BEFORE', 'AFTER']:
|
||||
sql.append(build_drop_trigger(operation, 'history_dataset_association', when))
|
||||
sql.append(build_drop_trigger(operation, 'history_dataset_collection_association', when))
|
||||
|
||||
return sql
|
||||
|
||||
|
||||
Reference in New Issue
Block a user