diff --git a/migration/19.12/migrateContacts.php b/migration/19.12/migrateContacts.php
index c6e9a85e87174ae499f32bec8dc911288fc8f1fb..fd5c00cbf30be47b5d171daa0dede047f647e6be 100644
--- a/migration/19.12/migrateContacts.php
+++ b/migration/19.12/migrateContacts.php
@@ -226,6 +226,7 @@ function migrateCustomField($args = [])
         if (!empty($value)) {
             $contact = \Contact\models\ContactModel::getById(['id' => $args['newContactId'], 'select' => ['custom_fields']]);
             $value = json_encode($value);
+            $value = str_replace("'", "''", $value);
             if (empty($contact['custom_fields'])) {
                 \Contact\models\ContactModel::update([
                     'postSet' => ['custom_fields' => "jsonb_set('{}', '{{$args['newCustomFields'][$key]}}', '{$value}')"],