summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Mancy <rmancy@redhat.com>2012-07-17 21:10:42 -0400
committerGerrit Code Review <gerrit@beaker-project.org>2012-07-17 21:10:42 -0400
commitd5bd6b97a02da2d54358250e84a9d723b267256f (patch)
tree60ac1c6c905db7093e701632959760ded3056ecc
parentd1f7c3a035564897ec12e7ab3d007b88ad7ef711 (diff)
parent6f54ef1736b52519549a3e4337e568acb7efafea (diff)
Merge "Add NOT NULL property to group_activity.group_id and add SQL statements to accomodate" into release-0.9.1
-rw-r--r--SchemaUpgrades/upgrade_0.9.1.txt19
-rw-r--r--Server/bkr/server/model.py3
2 files changed, 21 insertions, 1 deletions
diff --git a/SchemaUpgrades/upgrade_0.9.1.txt b/SchemaUpgrades/upgrade_0.9.1.txt
index 744df14..f471cf8 100644
--- a/SchemaUpgrades/upgrade_0.9.1.txt
+++ b/SchemaUpgrades/upgrade_0.9.1.txt
@@ -11,3 +11,22 @@ To roll back:
ALTER TABLE cpu_flag
MODIFY flag VARCHAR(10) DEFAULT NULL;
+
+
+Remove activity rows for deleted groups (840724).
+This will remove rows that fail the new non
+nullable constraint of group_activity.group_id
+-------------------------------------------------
+Run the following SQL:
+
+ DELETE FROM group_activity WHERE group_id IS NULL;
+ DELETE FROM activity WHERE type = 'group_activity' AND id NOT IN (SELECT id FROM group_activity);
+ ALTER TABLE group_activity
+ MODIFY group_id int(11) NOT NULL;
+
+
+To roll back:
+We can only rollback our group_activity.group_id modification.
+
+ ALTER TABLE group_activity
+ MODIFY group_id int(11) NULL;
diff --git a/Server/bkr/server/model.py b/Server/bkr/server/model.py
index 292fd27..7c1873e 100644
--- a/Server/bkr/server/model.py
+++ b/Server/bkr/server/model.py
@@ -718,7 +718,8 @@ recipeset_activity_table = Table('recipeset_activity', metadata,
group_activity_table = Table('group_activity', metadata,
Column('id', Integer, ForeignKey('activity.id'), primary_key=True),
- Column('group_id', Integer, ForeignKey('tg_group.group_id')),
+ Column('group_id', Integer, ForeignKey('tg_group.group_id'),
+ nullable=False),
mysql_engine='InnoDB',
)