aboutsummaryrefslogtreecommitdiffstats
path: root/db/schema_0033-body-areas-many-many.sql
diff options
context:
space:
mode:
Diffstat (limited to 'db/schema_0033-body-areas-many-many.sql')
-rw-r--r--db/schema_0033-body-areas-many-many.sql15
1 files changed, 15 insertions, 0 deletions
diff --git a/db/schema_0033-body-areas-many-many.sql b/db/schema_0033-body-areas-many-many.sql
new file mode 100644
index 000000000..e03f3fa44
--- /dev/null
+++ b/db/schema_0033-body-areas-many-many.sql
@@ -0,0 +1,15 @@
+begin;
+
+create table body_areas (
+ body_id integer not null references body(id),
+ area_id integer not null
+);
+create unique index body_areas_body_id_area_id_idx on body_areas(body_id, area_id);
+
+INSERT INTO body_areas (body_id, area_id)
+ SELECT id, area_id FROM body;
+
+ALTER TABLE body DROP COLUMN area_id;
+
+commit;
+