(core) reconcile webhook and widget description migrations

Summary:
Due to a mishap, two distinct migrations with the same migration
number were introduced into Grist. This diff reconciles them as
best we can, by adding another migration to make sure both desired
changes have run (and running them if not).

Test Plan:
updated a test; checked manually that documents
with different 38 migrations are handled as expected.

Reviewers: georgegevoian, jarek

Reviewed By: georgegevoian, jarek

Differential Revision: https://phab.getgrist.com/D3895
This commit is contained in:
Paul Fitzpatrick
2023-05-15 11:16:58 -04:00
parent 18ad39cba3
commit b58929f095
5 changed files with 39 additions and 17 deletions

View File

@@ -1205,13 +1205,32 @@ def migration37(tdset):
@migration(schema_version=38)
def migration38(tdset):
doc_actions = [add_column('_grist_Triggers', 'memo', 'Text'),
add_column('_grist_Triggers', 'label', 'Text'),
add_column('_grist_Triggers', 'enabled', 'Bool')]
triggers = list(actions.transpose_bulk_action(tdset.all_tables['_grist_Triggers']))
doc_actions.append(actions.BulkUpdateRecord(
'_grist_Triggers',
[t.id for t in triggers],
{'enabled': [True for t in triggers]}
))
"""
Through a mishap, this migration ended up conflicted across two version of Grist.
In one version, it added webhook related columns. In another it added a description
to widgets. Sorry if this impacted you. Migration 39 does the best we can to
smooth over the divergence, and this migration now does nothing (though in the
past it did one of two possible things).
"""
return tdset.apply_doc_actions([])
@migration(schema_version=39)
def migration39(tdset):
"""
Adds memo, label, and enabled flag to triggers (for webhooks).
Adds a description to widgets.
"""
doc_actions = []
if 'memo' not in tdset.all_tables['_grist_Triggers'].columns:
doc_actions += [add_column('_grist_Triggers', 'memo', 'Text'),
add_column('_grist_Triggers', 'label', 'Text'),
add_column('_grist_Triggers', 'enabled', 'Bool')]
triggers = list(actions.transpose_bulk_action(tdset.all_tables['_grist_Triggers']))
doc_actions.append(actions.BulkUpdateRecord(
'_grist_Triggers',
[t.id for t in triggers],
{'enabled': [True for t in triggers]}
))
if 'description' not in tdset.all_tables['_grist_Views_section'].columns:
doc_actions.append(add_column('_grist_Views_section', 'description', 'Text'))
return tdset.apply_doc_actions(doc_actions)

View File

@@ -15,7 +15,7 @@ import six
import actions
SCHEMA_VERSION = 38
SCHEMA_VERSION = 39
def make_column(col_id, col_type, formula='', isFormula=False):
return {
@@ -181,6 +181,7 @@ def schema_create_actions():
# TODO: rename this (e.g. to "sectionType").
make_column("parentKey", "Text"),
make_column("title", "Text"),
make_column("description", "Text"),
make_column("defaultWidth", "Int", formula="100"),
make_column("borderWidth", "Int", formula="1"),
make_column("theme", "Text"),