From 2b65fae741bc1d483db2df55dd00d8b1f2d8826f Mon Sep 17 00:00:00 2001
From: Tanner Prestegard <tanner.prestegard@ligo.org>
Date: Wed, 12 Dec 2018 10:54:49 -0600
Subject: [PATCH] Add BBH search (supposed to be for CWB)

---
 docs/user_docs/source/models.rst              |  2 +-
 .../migrations/0029_create_bbh_search.py      | 27 +++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)
 create mode 100644 gracedb/events/migrations/0029_create_bbh_search.py

diff --git a/docs/user_docs/source/models.rst b/docs/user_docs/source/models.rst
index 96825c0ef..66fa0ddfd 100644
--- a/docs/user_docs/source/models.rst
+++ b/docs/user_docs/source/models.rst
@@ -14,7 +14,7 @@ The different types of events in GraceDB are distinguished by the following para
 - ``Pipeline``: the data analysis software tool used make the detection 
     - values: ``MBTAOnline``, ``CWB``, ``CWB2G``, ``gstlal``, ``spiir``, ``HardwareInjection``, ``Fermi``, ``Swift``, ``SNEWS``, ``oLIB``
 - ``Search``: the search activity which led to the detection 
-    - values: ``AllSky``, ``AllSkyLong``, ``LowMass``, ``HighMass``, ``GRB``, ``Supernova``, ``MDC``
+    - values: ``AllSky``, ``AllSkyLong``, ``LowMass``, ``HighMass``, ``GRB``, ``Supernova``, ``MDC``, ``BBH``
 
 An individual "event stream" is specified by setting the values of these three parameters.
 For example, choosing ``Group=CBC``, ``Pipeline=gstlal``, and ``Search=LowMass`` selects the event stream consisting of low-mass inspiral events detected by the gstlal pipeline from the CBC group.
diff --git a/gracedb/events/migrations/0029_create_bbh_search.py b/gracedb/events/migrations/0029_create_bbh_search.py
new file mode 100644
index 000000000..29e9d63f2
--- /dev/null
+++ b/gracedb/events/migrations/0029_create_bbh_search.py
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.16 on 2018-12-12 16:48
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+SEARCH_NAME = 'BBH'
+
+def create_search(apps, schema_editor):
+    Search = apps.get_model('events', 'Search')
+
+    # Use get_or_create so that if the migration is unapplied
+    # then reapplied, we don't end up with multiples, since the
+    # name doesn't have to be unique (??, probably should be)
+    Search.objects.get_or_create(name=SEARCH_NAME)
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('events', '0028_make_labels_protected'),
+    ]
+
+    operations = [
+        migrations.RunPython(create_search, migrations.RunPython.noop),
+    ]
-- 
GitLab