Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

sol: implement the set_field for db migration #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions store/migrations/0002_cell_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
)



Expand Down