From 0c4e753b7739760b260ef63d83634edcdcec9e12 Mon Sep 17 00:00:00 2001 From: Igor Aleksanov Date: Fri, 6 Sep 2024 11:11:35 +0400 Subject: [PATCH] Fix the migration --- ...5123059_rename-recurision-scheduler-level-vk-hash.down.sql | 1 + ...905123059_rename-recurision-scheduler-level-vk-hash.up.sql | 4 +++- ...5124208_rename-recurision-scheduler-level-vk-hash.down.sql | 1 + ...905124208_rename-recurision-scheduler-level-vk-hash.up.sql | 4 +++- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/lib/dal/migrations/20240905123059_rename-recurision-scheduler-level-vk-hash.down.sql b/core/lib/dal/migrations/20240905123059_rename-recurision-scheduler-level-vk-hash.down.sql index 6a87a365038d..daa108d4ff39 100644 --- a/core/lib/dal/migrations/20240905123059_rename-recurision-scheduler-level-vk-hash.down.sql +++ b/core/lib/dal/migrations/20240905123059_rename-recurision-scheduler-level-vk-hash.down.sql @@ -1,2 +1,3 @@ UPDATE protocol_patches SET recursion_scheduler_level_vk_hash = snark_wrapper_vk_hash WHERE recursion_scheduler_level_vk_hash = ''::bytea; ALTER TABLE protocol_patches DROP COLUMN snark_wrapper_vk_hash; +ALTER TABLE protocol_patches ALTER COLUMN recursion_scheduler_level_vk_hash DROP DEFAULT; diff --git a/core/lib/dal/migrations/20240905123059_rename-recurision-scheduler-level-vk-hash.up.sql b/core/lib/dal/migrations/20240905123059_rename-recurision-scheduler-level-vk-hash.up.sql index 3aff177f6189..730b3a50d8a0 100644 --- a/core/lib/dal/migrations/20240905123059_rename-recurision-scheduler-level-vk-hash.up.sql +++ b/core/lib/dal/migrations/20240905123059_rename-recurision-scheduler-level-vk-hash.up.sql @@ -1,6 +1,8 @@ -ALTER TABLE protocol_patches ADD COLUMN snark_wrapper_vk_hash BYTEA NOT NULL; +ALTER TABLE protocol_patches ADD COLUMN snark_wrapper_vk_hash BYTEA NOT NULL DEFAULT ''::bytea; ALTER TABLE protocol_patches ALTER COLUMN recursion_scheduler_level_vk_hash SET DEFAULT ''::bytea; UPDATE protocol_patches SET snark_wrapper_vk_hash = recursion_scheduler_level_vk_hash; +-- Default was only needed to migrate old rows, we don't want this field to be forgotten by accident after migration. +ALTER TABLE protocol_patches ALTER COLUMN snark_wrapper_vk_hash DROP DEFAULT; -- Old column should be removed once the migration is on the mainnet. COMMENT ON COLUMN protocol_patches.recursion_scheduler_level_vk_hash IS 'This column is deprecated and will be removed in the future. Use snark_wrapper_vk_hash instead.'; diff --git a/prover/crates/lib/prover_dal/migrations/20240905124208_rename-recurision-scheduler-level-vk-hash.down.sql b/prover/crates/lib/prover_dal/migrations/20240905124208_rename-recurision-scheduler-level-vk-hash.down.sql index 169f9cc64c0d..8d1681440769 100644 --- a/prover/crates/lib/prover_dal/migrations/20240905124208_rename-recurision-scheduler-level-vk-hash.down.sql +++ b/prover/crates/lib/prover_dal/migrations/20240905124208_rename-recurision-scheduler-level-vk-hash.down.sql @@ -1,2 +1,3 @@ UPDATE prover_fri_protocol_versions SET recursion_scheduler_level_vk_hash = snark_wrapper_vk_hash WHERE recursion_scheduler_level_vk_hash = ''::bytea; ALTER TABLE prover_fri_protocol_versions DROP COLUMN snark_wrapper_vk_hash; +ALTER TABLE prover_fri_protocol_versions ALTER COLUMN recursion_scheduler_level_vk_hash DROP DEFAULT; diff --git a/prover/crates/lib/prover_dal/migrations/20240905124208_rename-recurision-scheduler-level-vk-hash.up.sql b/prover/crates/lib/prover_dal/migrations/20240905124208_rename-recurision-scheduler-level-vk-hash.up.sql index a3dc5d3e89ad..98eb1ee791c2 100644 --- a/prover/crates/lib/prover_dal/migrations/20240905124208_rename-recurision-scheduler-level-vk-hash.up.sql +++ b/prover/crates/lib/prover_dal/migrations/20240905124208_rename-recurision-scheduler-level-vk-hash.up.sql @@ -1,6 +1,8 @@ -ALTER TABLE prover_fri_protocol_versions ADD COLUMN snark_wrapper_vk_hash BYTEA NOT NULL; +ALTER TABLE prover_fri_protocol_versions ADD COLUMN snark_wrapper_vk_hash BYTEA NOT NULL DEFAULT ''::bytea; ALTER TABLE prover_fri_protocol_versions ALTER COLUMN recursion_scheduler_level_vk_hash SET DEFAULT ''::bytea; UPDATE prover_fri_protocol_versions SET snark_wrapper_vk_hash = recursion_scheduler_level_vk_hash; +-- Default was only needed to migrate old rows, we don't want this field to be forgotten by accident after migration. +ALTER TABLE prover_fri_protocol_versions ALTER COLUMN snark_wrapper_vk_hash DROP DEFAULT; -- Old column should be removed once the migration is on the mainnet. COMMENT ON COLUMN prover_fri_protocol_versions.recursion_scheduler_level_vk_hash IS 'This column is deprecated and will be removed in the future. Use snark_wrapper_vk_hash instead.';