From 5c75b7f44dc39390849f0835da66d4e7538b21c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Greinhofer?= Date: Sun, 1 Sep 2024 15:28:05 -0500 Subject: [PATCH] Fix the BNA Pipeline entity (#140) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the fargate price foreign key in the BNA Pipeline table. Signed-off-by: Rémy Greinhofer --- docs/database.dbml | 4 ++-- docs/database.sql | 6 +++--- docs/database.svg | 2 +- entity/src/entities/bna_pipeline.rs | 4 ++-- entity/src/wrappers/bna_pipeline.rs | 12 ++++++------ ...m20240202_004130_brokenspoke_analyzer_pipeline.rs | 6 +++--- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/database.dbml b/docs/database.dbml index 9964fe6..d6cde54 100644 --- a/docs/database.dbml +++ b/docs/database.dbml @@ -6,7 +6,7 @@ Table "bna_pipeline" { "state_machine_id" uuid [pk, not null] "step" "character varying" "sqs_message" json - "fargate_price" integer + "fargate_price_id" integer "fargate_task_arn" "character varying" "s3_bucket" "character varying" "status" "character varying" [not null, default: `'Pending'::charactervarying`] @@ -185,7 +185,7 @@ Table "us_state" { } } -Ref "bna_pipeline_fargate_price_fkey":"fargate_price"."id" < "bna_pipeline"."fargate_price" +Ref "bna_pipeline_fargate_price_id_fkey":"fargate_price"."id" < "bna_pipeline"."fargate_price_id" Ref "bna_pipeline_status_fkey":"bna_pipeline_status"."status" < "bna_pipeline"."status" diff --git a/docs/database.sql b/docs/database.sql index 3f9d6a3..727bde9 100644 --- a/docs/database.sql +++ b/docs/database.sql @@ -39,7 +39,7 @@ CREATE TABLE public.bna_pipeline ( state_machine_id uuid NOT NULL, step character varying, sqs_message json, - fargate_price integer, + fargate_price_id integer, fargate_task_arn character varying, s3_bucket character varying, status character varying DEFAULT 'Pending'::character varying NOT NULL, @@ -715,11 +715,11 @@ CREATE INDEX us_state_fips_code_idx ON public.us_state USING btree (fips_code); -- --- Name: bna_pipeline bna_pipeline_fargate_price_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- Name: bna_pipeline bna_pipeline_fargate_price_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.bna_pipeline - ADD CONSTRAINT bna_pipeline_fargate_price_fkey FOREIGN KEY (fargate_price) REFERENCES public.fargate_price(id); + ADD CONSTRAINT bna_pipeline_fargate_price_id_fkey FOREIGN KEY (fargate_price_id) REFERENCES public.fargate_price(id); -- diff --git a/docs/database.svg b/docs/database.svg index ddc4daa..98d9ad0 100644 --- a/docs/database.svg +++ b/docs/database.svg @@ -139,7 +139,7 @@ json -fargate_price     +fargate_price_id     integer diff --git a/entity/src/entities/bna_pipeline.rs b/entity/src/entities/bna_pipeline.rs index f0d82e6..a5bcb65 100644 --- a/entity/src/entities/bna_pipeline.rs +++ b/entity/src/entities/bna_pipeline.rs @@ -10,7 +10,7 @@ pub struct Model { pub state_machine_id: Uuid, pub step: Option, pub sqs_message: Option, - pub fargate_price: Option, + pub fargate_price_id: Option, pub fargate_task_arn: Option, pub s3_bucket: Option, pub status: String, @@ -41,7 +41,7 @@ pub enum Relation { BnaPipelineStep, #[sea_orm( belongs_to = "super::fargate_price::Entity", - from = "Column::FargatePrice", + from = "Column::FargatePriceId", to = "super::fargate_price::Column::Id", on_update = "NoAction", on_delete = "NoAction" diff --git a/entity/src/wrappers/bna_pipeline.rs b/entity/src/wrappers/bna_pipeline.rs index 936c51f..e7dda31 100644 --- a/entity/src/wrappers/bna_pipeline.rs +++ b/entity/src/wrappers/bna_pipeline.rs @@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize}; pub struct BNAPipelinePost { pub cost: Option, pub end_time: Option, - pub fargate_price: Option, + pub fargate_price_id: Option, pub fargate_task_arn: Option, pub result_posted: Option, pub s3_bucket: Option, @@ -26,16 +26,16 @@ impl IntoActiveModel for BNAPipelinePost { bna_pipeline::ActiveModel { cost: ActiveValue::Set(self.cost), end_time: ActiveValue::Set(self.end_time), + fargate_price_id: ActiveValue::Set(self.fargate_price_id), fargate_task_arn: ActiveValue::Set(self.fargate_task_arn), results_posted: ActiveValue::Set(self.result_posted), s3_bucket: ActiveValue::Set(self.s3_bucket), sqs_message: ActiveValue::Set(self.sqs_message), start_time: ActiveValue::Set(self.start_time), state_machine_id: ActiveValue::Set(self.state_machine_id), + status: ActiveValue::Set(self.status), step: ActiveValue::Set(self.step), torn_down: ActiveValue::Set(self.torn_down), - fargate_price: ActiveValue::Set(self.fargate_price), - status: ActiveValue::Set(self.status), } } } @@ -44,7 +44,7 @@ impl IntoActiveModel for BNAPipelinePost { pub struct BNAPipelinePatch { pub cost: Option>, pub end_time: Option>, - pub fargate_price: Option>, + pub fargate_price_id: Option>, pub fargate_task_arn: Option>, pub neon_branch_id: Option>, pub result_posted: Option>, @@ -77,8 +77,8 @@ impl IntoActiveModel for BNAPipelinePatch { results_posted: self .result_posted .map_or(ActiveValue::NotSet, ActiveValue::Set), - fargate_price: self - .fargate_price + fargate_price_id: self + .fargate_price_id .map_or(ActiveValue::NotSet, ActiveValue::Set), status: self.status.map_or(ActiveValue::NotSet, ActiveValue::Set), } diff --git a/migration/src/m20240202_004130_brokenspoke_analyzer_pipeline.rs b/migration/src/m20240202_004130_brokenspoke_analyzer_pipeline.rs index 2bb9b80..545b797 100644 --- a/migration/src/m20240202_004130_brokenspoke_analyzer_pipeline.rs +++ b/migration/src/m20240202_004130_brokenspoke_analyzer_pipeline.rs @@ -59,7 +59,7 @@ impl MigrationTrait for Migration { .col(uuid(BNAPipeline::StateMachineId).primary_key()) .col(string_null(BNAPipeline::Step)) .col(json_null(BNAPipeline::SqsMessage)) - .col(integer_null(BNAPipeline::FargatePrice)) + .col(integer_null(BNAPipeline::FargatePriceId)) .col(string_null(BNAPipeline::FargateTaskARN)) .col(string_null(BNAPipeline::S3Bucket)) .col(string(BNAPipeline::Status).default("Pending".to_string())) @@ -80,7 +80,7 @@ impl MigrationTrait for Migration { ) .foreign_key( ForeignKey::create() - .from(BNAPipeline::Table, BNAPipeline::FargatePrice) + .from(BNAPipeline::Table, BNAPipeline::FargatePriceId) .to(FargatePrice::Table, FargatePrice::Id), ) .to_owned(), @@ -112,7 +112,7 @@ enum BNAPipeline { Table, Cost, EndTime, - FargatePrice, + FargatePriceId, FargateTaskARN, ResultsPosted, S3Bucket,