Skip to content

Revision file

Example Revision File

Below is an example of a revision file that gets generated by the liminal revision command. This flow was heavily inspired by the Alembic migration workflow. When liminal upgrade ... is run, the operations in the upgrade() function are executed and when liminal downgrade ... is run, the operations in the downgrade() function are executed. Each revision is linearly linked to a previous revision through the IDs, creating a timeline of revisions/operations. This allows for the user to traverse the history of their Benchling model.

'''
test

Revision ID: c3a9cd009713
Revises: d28335bffaba
Create Date: 2024-10-26 10:33:26.390965
'''

import liminal.external as b

# revision identifiers, used by Liminal.
revision = "c3a9cd009713"
down_revision = "d28335bffaba"


# ### commands auto generated by Liminal - please review (and adjust if needed)! ###
def upgrade() -> list[b.BaseOperation]:
    return [b.ArchiveEntitySchemaField('pizza', 'dough')]

# ### commands auto generated by Liminal - please review (and adjust if needed)! ###
def downgrade() -> list[b.BaseOperation]:
    return [b.UnarchiveEntitySchemaField('pizza', 'dough')]

Warning

Auto-generated revision files cannot automatically detect changes to warehouse names. This is because warehouse names are used as keys so when the key, Liminal will think it is a new schema/field. To address this, you must manually edit the revision file.

Updating Entity Schema warehouse name:

# Liminal will think that you are trying to create a new entity schema and archive the renamed one.
# Instead, replace autogenerated operations with...
b.UpdateEntitySchema('old_warehouse_name', 
    b.BaseSchemaProperties(warehouse_name='new_warehouse_name')
)

Updating Entity Schema Field warehouse name:

# Liminal will think that you are trying to create a new entity schema field and archive the renamed one.
# Instead, replace autogenerated operations with...
b.UpdateEntitySchemaField('entity_schema_warehouse_name', 'field_warehouse_name', 
b.BaseFieldProperties(warehouse_name='new_warehouse_field_name')
)

Updating Dropdown warehouse name:

b.UpdateDropdownName('old_warehouse_name', 'new_warehouse_name')