Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function for rollback of table version #195

Open
anngvu opened this issue Oct 16, 2024 · 0 comments
Open

Function for rollback of table version #195

anngvu opened this issue Oct 16, 2024 · 0 comments

Comments

@anngvu
Copy link
Contributor

anngvu commented Oct 16, 2024

Low priority because we don't expect to use this more than once a year, and there might be a native rollback function/button someday (see most closely-related ticket PLFM-4607). But for anyone interested in contributing to the package and making a "real" function out of this, here is the code in Python:

import synapseclient
from synapseclient import Table


syn = synapseclient.Synapse()
syn.login()

# Note: this is a simple case where the rollback version applied has the same schema as the current
# When rolling back to a different schema, will have to update the schema of the current table first

# Table of interest
table_id = "syn16787123"

# To replace a table, first delete all rows
tb_current = syn.tableQuery(f"select * from {table_id}")
tb_current = syn.delete(tb_current)

# Get data from desired snapshot
rollback_version = syn.tableQuery(f"select * from {table_id}.154", includeRowIdAndRowVersion=False)

# Update with the snapshot's data
table = syn.store(Table(table_id, rollback_version.filepath))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant