Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14010742
D10799.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D10799.diff
View Options
diff --git a/resources/sql/autopatches/20141106.uniqdrafts.php b/resources/sql/autopatches/20141106.uniqdrafts.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20141106.uniqdrafts.php
@@ -0,0 +1,30 @@
+<?php
+
+// Destroy duplicate drafts before storage adjustment adds a unique key to this
+// table. See T1191. We retain the newest draft.
+
+// (We can't easily do this in a single SQL statement because MySQL won't let us
+// modify a table that's joined in a subquery.)
+
+$table = new DifferentialDraft();
+$conn_w = $table->establishConnection('w');
+
+$duplicates = queryfx_all(
+ $conn_w,
+ 'SELECT DISTINCT u.id id FROM %T u
+ JOIN %T v
+ ON u.objectPHID = v.objectPHID
+ AND u.authorPHID = v.authorPHID
+ AND u.draftKey = v.draftKey
+ AND u.id < v.id',
+ $table->getTableName(),
+ $table->getTableName());
+
+$duplicates = ipull($duplicates, 'id');
+foreach (PhabricatorLiskDAO::chunkSQL($duplicates) as $chunk) {
+ queryfx(
+ $conn_w,
+ 'DELETE FROM %T WHERE id IN (%Q)',
+ $table->getTableName(),
+ $chunk);
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 1, 12:11 PM (2 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6713369
Default Alt Text
D10799.diff (1 KB)
Attached To
Mode
D10799: Force Differential draft uniqueness
Attached
Detach File
Event Timeline
Log In to Comment