diff --git a/store/migrations/0002_cell_field.py b/store/migrations/0002_cell_field.py index 7a0e9d0..aa8d149 100644 --- a/store/migrations/0002_cell_field.py +++ b/store/migrations/0002_cell_field.py @@ -5,8 +5,16 @@ def set_field(apps, schema_editor): - # Complete this function - raise NotImplementedError + migrations.RunSQL( + """update store.cell set field_id = t.field_id + from ( + SELECT f.id as field_id, c.id as cell_id + FROM store_field f + join store_record r on f.schema_id = r.schema_id + join store_cell c on c.field_name = f.name and c.record_id = r.id + ) t + where store_cell.id = t.cell_id""" + )