Skip to content

Commit

Permalink
add ccip cap spec migration
Browse files Browse the repository at this point in the history
  • Loading branch information
makramkd committed Jun 7, 2024
1 parent 0d95942 commit f289e0b
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/services/job/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ type Job struct {
WorkflowSpec *WorkflowSpec
StandardCapabilitiesSpecID *int32
StandardCapabilitiesSpec *StandardCapabilitiesSpec
CCIPSpecID *int32
CCIPBootstrapSpecID *int32
JobSpecErrors []SpecError
Type Type `toml:"type"`
SchemaVersion uint32 `toml:"schemaVersion"`
Expand Down
89 changes: 89 additions & 0 deletions core/store/migrate/migrations/0243_ccip_capability_specs.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
-- +goose Up
-- +goose StatementBegin
CREATE TABLE ccip_specs(
id BIGSERIAL PRIMARY KEY,
capability_version TEXT NOT NULL,
capability_labelled_name TEXT NOT NULL,
ocr_key_bundle_ids JSONB NOT NULL,
transmitter_ids JSONB NOT NULL,
p2p_key_id TEXT NOT NULL,
p2pv2_bootstrappers TEXT[] NOT NULL,
relay_configs JSONB NOT NULL,
plugin_config JSONB NOT NULL,
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
updated_at TIMESTAMP WITH TIME ZONE NOT NULL
);

CREATE TABLE ccip_bootstrap_specs(
id BIGSERIAL PRIMARY KEY,
capability_version TEXT NOT NULL,
capability_labelled_name TEXT NOT NULL,
relay_config JSONB NOT NULL,
monitoring_endpoint TEXT,
blockchain_timeout BIGINT,
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
updated_at TIMESTAMP WITH TIME ZONE NOT NULL
);

ALTER TABLE jobs
ADD COLUMN ccip_spec_id INT REFERENCES ccip_specs (id),
ADD COLUMN ccip_bootstrap_spec_id INT REFERENCES ccip_bootstrap_specs (id),
DROP CONSTRAINT chk_specs,
ADD CONSTRAINT chk_specs CHECK (
num_nonnulls(
ocr_oracle_spec_id, ocr2_oracle_spec_id,
direct_request_spec_id, flux_monitor_spec_id,
keeper_spec_id, cron_spec_id, webhook_spec_id,
vrf_spec_id, blockhash_store_spec_id,
block_header_feeder_spec_id, bootstrap_spec_id,
gateway_spec_id,
legacy_gas_station_server_spec_id,
legacy_gas_station_sidecar_spec_id,
eal_spec_id,
workflow_spec_id,
standard_capabilities_spec_id,
ccip_spec_id,
ccip_bootstrap_spec_id,
CASE "type"
WHEN 'stream'
THEN 1
ELSE NULL
END -- 'stream' type lacks a spec but should not cause validation to fail
) = 1
);
-- +goose StatementEnd

-- +goose Down
-- +goose StatementBegin
ALTER TABLE jobs
DROP CONSTRAINT chk_specs,
ADD CONSTRAINT chk_specs CHECK (
num_nonnulls(
ocr_oracle_spec_id, ocr2_oracle_spec_id,
direct_request_spec_id, flux_monitor_spec_id,
keeper_spec_id, cron_spec_id, webhook_spec_id,
vrf_spec_id, blockhash_store_spec_id,
block_header_feeder_spec_id, bootstrap_spec_id,
gateway_spec_id,
legacy_gas_station_server_spec_id,
legacy_gas_station_sidecar_spec_id,
eal_spec_id,
workflow_spec_id,
standard_capabilities_spec_id,
CASE "type"
WHEN 'stream'
THEN 1
ELSE NULL
END -- 'stream' type lacks a spec but should not cause validation to fail
) = 1
);

ALTER TABLE jobs
DROP COLUMN ccip_spec_id;

ALTER TABLE jobs
DROP COLUMN ccip_bootstrap_spec_id;

DROP TABLE ccip_specs;
DROP TABLE ccip_bootstrap_specs;
-- +goose StatementEnd

0 comments on commit f289e0b

Please sign in to comment.