<p></p>
<pre><code>StandardError: An error has occurred, this and all later migrations canceled:
=== Dangerous operation detected #strong_migrations ===
Adding a column with a non-null default blocks reads and writes while the entire table is rewritten.
Instead, add the column without a default value, then change the default.
class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.1]
def up
add_column :active_storage_blobs, :service_name, :string
change_column_default :active_storage_blobs, :service_name, :local
end
def down
remove_column :active_storage_blobs, :service_name
end
end
Then backfill the existing rows in the Rails console or a separate migration with disable_ddl_transaction!.
class BackfillAddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.1]
disable_ddl_transaction!
def up
ActiveStorageBlob.unscoped.in_batches do |relation|
relation.update_all service_name: :local
sleep(0.01)
end
end
end
Then add the NOT NULL constraint in separate migrations.
</code></pre>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/issues/3204">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLMD7E64O2MGOQTUN5TTPJLJFANCNFSM45NJAF3A">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AAK2OLJRYGJK6PK3I6LK3IDTPJLJFA5CNFSM45NJAF3KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4NNACBAQ.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/issues/3204",
"url": "https://github.com/openstreetmap/openstreetmap-website/issues/3204",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>