-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BCF-2637 Add evm chain id removal migrations (#10669)
* Add evm chain id removal migrations * Remove _test db url check for 0195 evm chain id migration * Improve 0195 migration, improve error msg and sql string constant names * Update 0195 migration to only add/remove evmChainID not nil constraints * Remove dangling err handling (leftover from evmChainID removal) * Update 0195 migration naming * Add helper function for not null evmChainID migration * Update changelog for evm chain id not null migration helper function * Update error message for sql open in shell MigrateDatabase * Fix job_orm_test test that set evm_chain_id to null * Fix evmChainID migration helper err when db is init for the first time * Move goose migration ver check for evmChainID migration in helper func
- Loading branch information
Showing
6 changed files
with
131 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
core/store/migrate/migrations/0195_add_not_null_to_evm_chain_id_in_job_specs.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package migrations | ||
|
||
import ( | ||
"context" | ||
"database/sql" | ||
|
||
"github.com/pkg/errors" | ||
"github.com/pressly/goose/v3" | ||
) | ||
|
||
func init() { | ||
goose.AddMigrationContext(Up195, Down195) | ||
} | ||
|
||
const ( | ||
addNullConstraintsToSpecs = ` | ||
ALTER TABLE direct_request_specs ALTER COLUMN evm_chain_id SET NOT NULL; | ||
ALTER TABLE flux_monitor_specs ALTER COLUMN evm_chain_id SET NOT NULL; | ||
ALTER TABLE ocr_oracle_specs ALTER COLUMN evm_chain_id SET NOT NULL; | ||
ALTER TABLE keeper_specs ALTER COLUMN evm_chain_id SET NOT NULL; | ||
ALTER TABLE vrf_specs ALTER COLUMN evm_chain_id SET NOT NULL; | ||
ALTER TABLE blockhash_store_specs ALTER COLUMN evm_chain_id SET NOT NULL; | ||
ALTER TABLE block_header_feeder_specs ALTER COLUMN evm_chain_id SET NOT NULL; | ||
` | ||
|
||
dropNullConstraintsFromSpecs = ` | ||
ALTER TABLE direct_request_specs ALTER COLUMN evm_chain_id DROP NOT NULL; | ||
ALTER TABLE flux_monitor_specs ALTER COLUMN evm_chain_id DROP NOT NULL; | ||
ALTER TABLE ocr_oracle_specs ALTER COLUMN evm_chain_id DROP NOT NULL; | ||
ALTER TABLE keeper_specs ALTER COLUMN evm_chain_id DROP NOT NULL; | ||
ALTER TABLE vrf_specs ALTER COLUMN evm_chain_id DROP NOT NULL; | ||
ALTER TABLE blockhash_store_specs ALTER COLUMN evm_chain_id DROP NOT NULL; | ||
ALTER TABLE block_header_feeder_specs ALTER COLUMN evm_chain_id DROP NOT NULL; | ||
` | ||
) | ||
|
||
// nolint | ||
func Up195(ctx context.Context, tx *sql.Tx) error { | ||
_, err := tx.ExecContext(ctx, addNullConstraintsToSpecs) | ||
return errors.Wrap(err, "failed to add null constraints") | ||
} | ||
|
||
// nolint | ||
func Down195(ctx context.Context, tx *sql.Tx) error { | ||
if _, err := tx.ExecContext(ctx, dropNullConstraintsFromSpecs); err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters