Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15391706
D21818.id51998.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
D21818.id51998.diff
View Options
diff --git a/resources/sql/autopatches/20220512.file.02.migrate.php b/resources/sql/autopatches/20220512.file.02.migrate.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20220512.file.02.migrate.php
@@ -0,0 +1,52 @@
+<?php
+
+$attachment_table = new PhabricatorFileAttachment();
+$attachment_conn = $attachment_table->establishConnection('w');
+
+$src_cursor = '';
+$dst_cursor = '';
+
+while (true) {
+ $rows = queryfx_all(
+ $attachment_conn,
+ 'SELECT src, dst, dateCreated FROM %T
+ WHERE type = 26 AND (src > %s OR (src = %s AND dst > %s))
+ ORDER BY src ASC, type ASC, dst ASC LIMIT %d',
+ 'edge',
+ $src_cursor,
+ $src_cursor,
+ $dst_cursor,
+ 10000);
+
+ if (!$rows) {
+ break;
+ }
+
+ $sql = array();
+ foreach ($rows as $row) {
+ $sql[] = qsprintf(
+ $attachment_conn,
+ '(%s, %s, %s, %ns, %d, %d)',
+ $row['dst'],
+ $row['src'],
+ PhabricatorFileAttachment::MODE_ATTACH,
+ null,
+ $row['dateCreated'],
+ $row['dateCreated']);
+ }
+
+ foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) {
+ queryfx(
+ $attachment_conn,
+ 'INSERT IGNORE INTO %R
+ (objectPHID, filePHID, attachmentMode, attacherPHID,
+ dateCreated, dateModified)
+ VALUES %LQ',
+ $attachment_table,
+ $chunk);
+ }
+
+ $last = last($rows);
+ $src_cursor = $last['src'];
+ $dst_cursor = $last['dst'];
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 16, 11:15 AM (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7706917
Default Alt Text
D21818.id51998.diff (1 KB)
Attached To
Mode
D21818: Copy file attachment edges to new storage
Attached
Detach File
Event Timeline
Log In to Comment