From 4e608f9caa9dcb26a246ead6ec9859e952a97daf Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Fri, 17 May 2019 09:32:30 -0700 Subject: [PATCH 1/7] drop the unused sequence in migration.id --- docs/modules/Conch::DB::Result::Migration.md | 2 -- lib/Conch/DB/Result/Migration.pm | 13 +++------ sql/migrations/0101-migration-table.sql | 7 +++++ sql/schema.sql | 28 -------------------- 4 files changed, 10 insertions(+), 40 deletions(-) create mode 100644 sql/migrations/0101-migration-table.sql diff --git a/docs/modules/Conch::DB::Result::Migration.md b/docs/modules/Conch::DB::Result::Migration.md index 9999db64e..dd28a9d2b 100644 --- a/docs/modules/Conch::DB::Result::Migration.md +++ b/docs/modules/Conch::DB::Result::Migration.md @@ -12,9 +12,7 @@ Conch::DB::Result::Migration ``` data_type: 'integer' -is_auto_increment: 1 is_nullable: 0 -sequence: 'migration_id_seq' ``` ## created diff --git a/lib/Conch/DB/Result/Migration.pm b/lib/Conch/DB/Result/Migration.pm index 43fce11c1..6ecc1a72a 100644 --- a/lib/Conch/DB/Result/Migration.pm +++ b/lib/Conch/DB/Result/Migration.pm @@ -31,9 +31,7 @@ __PACKAGE__->table("migration"); =head2 id data_type: 'integer' - is_auto_increment: 1 is_nullable: 0 - sequence: 'migration_id_seq' =head2 created @@ -46,12 +44,7 @@ __PACKAGE__->table("migration"); __PACKAGE__->add_columns( "id", - { - data_type => "integer", - is_auto_increment => 1, - is_nullable => 0, - sequence => "migration_id_seq", - }, + { data_type => "integer", is_nullable => 0 }, "created", { data_type => "timestamp with time zone", @@ -74,8 +67,8 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("id"); -# Created by DBIx::Class::Schema::Loader v0.07049 @ 2018-09-17 14:52:33 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:hyl49PiJbIKla/K14uYZTQ +# Created by DBIx::Class::Schema::Loader v0.07049 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:eZuUEhBQKuK4OzJ1T7AxjQ 1; __END__ diff --git a/sql/migrations/0101-migration-table.sql b/sql/migrations/0101-migration-table.sql new file mode 100644 index 000000000..2685db491 --- /dev/null +++ b/sql/migrations/0101-migration-table.sql @@ -0,0 +1,7 @@ +SELECT run_migration(101, $$ + + -- migration numbers are always manually selected; this sequence serves no purpose. + alter table migration alter column id drop default; + drop sequence migration_id_seq; + +$$); diff --git a/sql/schema.sql b/sql/schema.sql index ed952faf7..5149307cd 100644 --- a/sql/schema.sql +++ b/sql/schema.sql @@ -460,27 +460,6 @@ CREATE TABLE public.migration ( ALTER TABLE public.migration OWNER TO conch; --- --- Name: migration_id_seq; Type: SEQUENCE; Schema: public; Owner: conch --- - -CREATE SEQUENCE public.migration_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public.migration_id_seq OWNER TO conch; - --- --- Name: migration_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: conch --- - -ALTER SEQUENCE public.migration_id_seq OWNED BY public.migration.id; - - -- -- Name: rack; Type: TABLE; Schema: public; Owner: conch -- @@ -749,13 +728,6 @@ CREATE TABLE public.workspace_rack ( ALTER TABLE public.workspace_rack OWNER TO conch; --- --- Name: migration id; Type: DEFAULT; Schema: public; Owner: conch --- - -ALTER TABLE ONLY public.migration ALTER COLUMN id SET DEFAULT nextval('public.migration_id_seq'::regclass); - - -- -- Name: datacenter datacenter_pkey; Type: CONSTRAINT; Schema: public; Owner: conch -- From 6272a7a1157050e7fbde41149a9f5d67070b71a9 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 30 May 2019 11:10:21 -0700 Subject: [PATCH 2/7] drop all uses of the unnecessary uuid-ossp extension See the last section of https://www.postgresql.org/docs/9.6/uuid-ossp.html --- docs/modules/Conch::DB::Result::Validation.md | 2 +- .../Conch::DB::Result::ValidationPlan.md | 2 +- .../Conch::DB::Result::ValidationResult.md | 2 +- .../Conch::DB::Result::ValidationState.md | 2 +- docs/modules/Conch::DB::Result::Workspace.md | 2 +- lib/Conch/DB/Result/Validation.pm | 6 ++--- lib/Conch/DB/Result/ValidationPlan.pm | 6 ++--- lib/Conch/DB/Result/ValidationResult.pm | 6 ++--- lib/Conch/DB/Result/ValidationState.pm | 6 ++--- lib/Conch/DB/Result/Workspace.pm | 6 ++--- sql/migrations/0102-drop-uuid-ossp.sql | 11 +++++++++ sql/schema.sql | 24 ++++--------------- 12 files changed, 36 insertions(+), 39 deletions(-) create mode 100644 sql/migrations/0102-drop-uuid-ossp.sql diff --git a/docs/modules/Conch::DB::Result::Validation.md b/docs/modules/Conch::DB::Result::Validation.md index 23f8dd548..9f8d167e0 100644 --- a/docs/modules/Conch::DB::Result::Validation.md +++ b/docs/modules/Conch::DB::Result::Validation.md @@ -12,7 +12,7 @@ Conch::DB::Result::Validation ``` data_type: 'uuid' -default_value: uuid_generate_v4() +default_value: gen_random_uuid() is_nullable: 0 size: 16 ``` diff --git a/docs/modules/Conch::DB::Result::ValidationPlan.md b/docs/modules/Conch::DB::Result::ValidationPlan.md index 7b2eb023d..2fd3097ec 100644 --- a/docs/modules/Conch::DB::Result::ValidationPlan.md +++ b/docs/modules/Conch::DB::Result::ValidationPlan.md @@ -12,7 +12,7 @@ Conch::DB::Result::ValidationPlan ``` data_type: 'uuid' -default_value: uuid_generate_v4() +default_value: gen_random_uuid() is_nullable: 0 size: 16 ``` diff --git a/docs/modules/Conch::DB::Result::ValidationResult.md b/docs/modules/Conch::DB::Result::ValidationResult.md index f580f6202..01926e899 100644 --- a/docs/modules/Conch::DB::Result::ValidationResult.md +++ b/docs/modules/Conch::DB::Result::ValidationResult.md @@ -12,7 +12,7 @@ Conch::DB::Result::ValidationResult ``` data_type: 'uuid' -default_value: uuid_generate_v4() +default_value: gen_random_uuid() is_nullable: 0 size: 16 ``` diff --git a/docs/modules/Conch::DB::Result::ValidationState.md b/docs/modules/Conch::DB::Result::ValidationState.md index dbe991cd2..4f04315c5 100644 --- a/docs/modules/Conch::DB::Result::ValidationState.md +++ b/docs/modules/Conch::DB::Result::ValidationState.md @@ -12,7 +12,7 @@ Conch::DB::Result::ValidationState ``` data_type: 'uuid' -default_value: uuid_generate_v4() +default_value: gen_random_uuid() is_nullable: 0 size: 16 ``` diff --git a/docs/modules/Conch::DB::Result::Workspace.md b/docs/modules/Conch::DB::Result::Workspace.md index 175cf2f12..64121c046 100644 --- a/docs/modules/Conch::DB::Result::Workspace.md +++ b/docs/modules/Conch::DB::Result::Workspace.md @@ -12,7 +12,7 @@ Conch::DB::Result::Workspace ``` data_type: 'uuid' -default_value: uuid_generate_v4() +default_value: gen_random_uuid() is_nullable: 0 size: 16 ``` diff --git a/lib/Conch/DB/Result/Validation.pm b/lib/Conch/DB/Result/Validation.pm index 3475c79fd..2ab72ed72 100644 --- a/lib/Conch/DB/Result/Validation.pm +++ b/lib/Conch/DB/Result/Validation.pm @@ -31,7 +31,7 @@ __PACKAGE__->table("validation"); =head2 id data_type: 'uuid' - default_value: uuid_generate_v4() + default_value: gen_random_uuid() is_nullable: 0 size: 16 @@ -80,7 +80,7 @@ __PACKAGE__->add_columns( "id", { data_type => "uuid", - default_value => \"uuid_generate_v4()", + default_value => \"gen_random_uuid()", is_nullable => 0, size => 16, }, @@ -186,7 +186,7 @@ __PACKAGE__->many_to_many( # Created by DBIx::Class::Schema::Loader v0.07049 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:KXO3aW6sCj8u1N2+OpYzhQ +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7TMTq8HbrTSucb+jym+imw __PACKAGE__->add_columns( '+module' => { is_serializable => 0 }, diff --git a/lib/Conch/DB/Result/ValidationPlan.pm b/lib/Conch/DB/Result/ValidationPlan.pm index c570b186b..740ae802a 100644 --- a/lib/Conch/DB/Result/ValidationPlan.pm +++ b/lib/Conch/DB/Result/ValidationPlan.pm @@ -31,7 +31,7 @@ __PACKAGE__->table("validation_plan"); =head2 id data_type: 'uuid' - default_value: uuid_generate_v4() + default_value: gen_random_uuid() is_nullable: 0 size: 16 @@ -63,7 +63,7 @@ __PACKAGE__->add_columns( "id", { data_type => "uuid", - default_value => \"uuid_generate_v4()", + default_value => \"gen_random_uuid()", is_nullable => 0, size => 16, }, @@ -138,7 +138,7 @@ __PACKAGE__->many_to_many("validations", "validation_plan_members", "validation" # Created by DBIx::Class::Schema::Loader v0.07049 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ZxCTbfKSl997ecwJ/FJ3+Q +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:pY3RQbK9VIIedyEO0h1hnw __PACKAGE__->add_columns( '+deactivated' => { is_serializable => 0 }, diff --git a/lib/Conch/DB/Result/ValidationResult.pm b/lib/Conch/DB/Result/ValidationResult.pm index 822a0e3a1..6e1d5bd02 100644 --- a/lib/Conch/DB/Result/ValidationResult.pm +++ b/lib/Conch/DB/Result/ValidationResult.pm @@ -31,7 +31,7 @@ __PACKAGE__->table("validation_result"); =head2 id data_type: 'uuid' - default_value: uuid_generate_v4() + default_value: gen_random_uuid() is_nullable: 0 size: 16 @@ -99,7 +99,7 @@ __PACKAGE__->add_columns( "id", { data_type => "uuid", - default_value => \"uuid_generate_v4()", + default_value => \"gen_random_uuid()", is_nullable => 0, size => 16, }, @@ -227,7 +227,7 @@ __PACKAGE__->many_to_many( # Created by DBIx::Class::Schema::Loader v0.07049 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:E0g/P81PqD6kJxx9zk0Lbw +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:L5ZgyNsNYfWBo+KYSmPVoQ __PACKAGE__->add_columns( '+created' => { is_serializable => 0 }, diff --git a/lib/Conch/DB/Result/ValidationState.pm b/lib/Conch/DB/Result/ValidationState.pm index da18b8236..545d6d92b 100644 --- a/lib/Conch/DB/Result/ValidationState.pm +++ b/lib/Conch/DB/Result/ValidationState.pm @@ -31,7 +31,7 @@ __PACKAGE__->table("validation_state"); =head2 id data_type: 'uuid' - default_value: uuid_generate_v4() + default_value: gen_random_uuid() is_nullable: 0 size: 16 @@ -79,7 +79,7 @@ __PACKAGE__->add_columns( "id", { data_type => "uuid", - default_value => \"uuid_generate_v4()", + default_value => \"gen_random_uuid()", is_nullable => 0, size => 16, }, @@ -199,7 +199,7 @@ __PACKAGE__->many_to_many( # Created by DBIx::Class::Schema::Loader v0.07049 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:tzscPQu3Gi3WqQEayjzsAQ +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:yN5z1kiYZILdKOK92ANSgA __PACKAGE__->add_columns( '+created' => { retrieve_on_insert => 1 }, diff --git a/lib/Conch/DB/Result/Workspace.pm b/lib/Conch/DB/Result/Workspace.pm index 91064abd0..de66fe1e8 100644 --- a/lib/Conch/DB/Result/Workspace.pm +++ b/lib/Conch/DB/Result/Workspace.pm @@ -31,7 +31,7 @@ __PACKAGE__->table("workspace"); =head2 id data_type: 'uuid' - default_value: uuid_generate_v4() + default_value: gen_random_uuid() is_nullable: 0 size: 16 @@ -58,7 +58,7 @@ __PACKAGE__->add_columns( "id", { data_type => "uuid", - default_value => \"uuid_generate_v4()", + default_value => \"gen_random_uuid()", is_nullable => 0, size => 16, }, @@ -175,7 +175,7 @@ __PACKAGE__->many_to_many("racks", "workspace_racks", "rack"); # Created by DBIx::Class::Schema::Loader v0.07049 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:RsBlQ3oLCLqT577UfUsn2g +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:jAQTz8eBEJas87XgWV7xbw use experimental 'signatures'; diff --git a/sql/migrations/0102-drop-uuid-ossp.sql b/sql/migrations/0102-drop-uuid-ossp.sql new file mode 100644 index 000000000..5886c0a21 --- /dev/null +++ b/sql/migrations/0102-drop-uuid-ossp.sql @@ -0,0 +1,11 @@ +SELECT run_migration(102, $$ + + alter table validation alter column id set default gen_random_uuid(); + alter table validation_plan alter column id set default gen_random_uuid(); + alter table validation_result alter column id set default gen_random_uuid(); + alter table validation_state alter column id set default gen_random_uuid(); + alter table workspace alter column id set default gen_random_uuid(); + + drop extension "uuid-ossp"; + +$$); diff --git a/sql/schema.sql b/sql/schema.sql index 5149307cd..bf430667b 100644 --- a/sql/schema.sql +++ b/sql/schema.sql @@ -44,20 +44,6 @@ CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public; COMMENT ON EXTENSION pgcrypto IS 'cryptographic functions'; --- --- Name: uuid-ossp; Type: EXTENSION; Schema: -; Owner: --- - -CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public; - - --- --- Name: EXTENSION "uuid-ossp"; Type: COMMENT; Schema: -; Owner: --- - -COMMENT ON EXTENSION "uuid-ossp" IS 'generate universally unique identifiers (UUIDs)'; - - -- -- Name: device_health_enum; Type: TYPE; Schema: public; Owner: conch -- @@ -612,7 +598,7 @@ ALTER TABLE public.user_workspace_role OWNER TO conch; -- CREATE TABLE public.validation ( - id uuid DEFAULT public.uuid_generate_v4() NOT NULL, + id uuid DEFAULT public.gen_random_uuid() NOT NULL, name text NOT NULL, version integer NOT NULL, description text NOT NULL, @@ -630,7 +616,7 @@ ALTER TABLE public.validation OWNER TO conch; -- CREATE TABLE public.validation_plan ( - id uuid DEFAULT public.uuid_generate_v4() NOT NULL, + id uuid DEFAULT public.gen_random_uuid() NOT NULL, name text NOT NULL, description text NOT NULL, created timestamp with time zone DEFAULT now() NOT NULL, @@ -657,7 +643,7 @@ ALTER TABLE public.validation_plan_member OWNER TO conch; -- CREATE TABLE public.validation_result ( - id uuid DEFAULT public.uuid_generate_v4() NOT NULL, + id uuid DEFAULT public.gen_random_uuid() NOT NULL, device_id text NOT NULL, hardware_product_id uuid NOT NULL, validation_id uuid NOT NULL, @@ -678,7 +664,7 @@ ALTER TABLE public.validation_result OWNER TO conch; -- CREATE TABLE public.validation_state ( - id uuid DEFAULT public.uuid_generate_v4() NOT NULL, + id uuid DEFAULT public.gen_random_uuid() NOT NULL, device_id text NOT NULL, validation_plan_id uuid NOT NULL, created timestamp with time zone DEFAULT now() NOT NULL, @@ -707,7 +693,7 @@ ALTER TABLE public.validation_state_member OWNER TO conch; -- CREATE TABLE public.workspace ( - id uuid DEFAULT public.uuid_generate_v4() NOT NULL, + id uuid DEFAULT public.gen_random_uuid() NOT NULL, name text NOT NULL, description text, parent_workspace_id uuid From 062c5de47f2e5279d219a76de18f67e02e41ce63 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Wed, 5 Jun 2019 13:34:42 -0700 Subject: [PATCH 3/7] validation_status tidy: drop "processing" from state, make "completed" not null "processing" has not been used as a state since ~Sept 2018, before which it was used as the initial state to put a validation_state record when it was created, and then (in theory) it was updated to its final value of error/fail/pass when report processing was complete. Some records ended up stuck in the initial state due to a bug that caused new records to be created instead. The remaining records stuck in limbo can be found and put into a more reasonable state. --- .../Conch::DB::Result::ValidationResult.md | 2 +- .../Conch::DB::Result::ValidationState.md | 4 +- json-schema/common.yaml | 2 - json-schema/response.yaml | 12 ++-- lib/Conch/Controller/DeviceReport.pm | 2 +- lib/Conch/DB/Result/ValidationResult.pm | 6 +- lib/Conch/DB/Result/ValidationState.pm | 10 +-- lib/Conch/ValidationSystem.pm | 1 - ...0103-validation_status_enum-processing.sql | 69 +++++++++++++++++++ sql/schema.sql | 5 +- 10 files changed, 87 insertions(+), 26 deletions(-) create mode 100644 sql/migrations/0103-validation_status_enum-processing.sql diff --git a/docs/modules/Conch::DB::Result::ValidationResult.md b/docs/modules/Conch::DB::Result::ValidationResult.md index 01926e899..01552a8f1 100644 --- a/docs/modules/Conch::DB::Result::ValidationResult.md +++ b/docs/modules/Conch::DB::Result::ValidationResult.md @@ -61,7 +61,7 @@ is_nullable: 1 ```perl data_type: 'enum' -extra: {custom_type_name => "validation_status_enum",list => ["error","fail","processing","pass"]} +extra: {custom_type_name => "validation_status_enum",list => ["error","fail","pass"]} is_nullable: 0 ``` diff --git a/docs/modules/Conch::DB::Result::ValidationState.md b/docs/modules/Conch::DB::Result::ValidationState.md index 4f04315c5..8233f0f46 100644 --- a/docs/modules/Conch::DB::Result::ValidationState.md +++ b/docs/modules/Conch::DB::Result::ValidationState.md @@ -47,7 +47,7 @@ original: {default_value => \"now()"} ```perl data_type: 'enum' -extra: {custom_type_name => "validation_status_enum",list => ["error","fail","processing","pass"]} +extra: {custom_type_name => "validation_status_enum",list => ["error","fail","pass"]} is_nullable: 0 ``` @@ -55,7 +55,7 @@ is_nullable: 0 ``` data_type: 'timestamp with time zone' -is_nullable: 1 +is_nullable: 0 ``` ## device\_report\_id diff --git a/json-schema/common.yaml b/json-schema/common.yaml index b75653b52..72a8dbbb5 100644 --- a/json-schema/common.yaml +++ b/json-schema/common.yaml @@ -67,10 +67,8 @@ definitions: description: corresponds to validation_status_enum in the database type: string enum: - # TODO: remove antiquated 'processing' - error - fail - - processing - pass non_empty_string: type: string diff --git a/json-schema/response.yaml b/json-schema/response.yaml index e78777430..d80b4f901 100644 --- a/json-schema/response.yaml +++ b/json-schema/response.yaml @@ -1086,10 +1086,8 @@ definitions: id: $ref: common.yaml#/definitions/uuid completed: - oneOf: - - type: 'null' - - type: string - format: date-time + type: string + format: date-time created: type: string format: date-time @@ -1122,10 +1120,8 @@ definitions: id: $ref: common.yaml#/definitions/uuid completed: - oneOf: - - type: 'null' - - type: string - format: date-time + type: string + format: date-time created: type: string format: date-time diff --git a/lib/Conch/Controller/DeviceReport.pm b/lib/Conch/Controller/DeviceReport.pm index 6ad86a1db..84dddeed6 100644 --- a/lib/Conch/Controller/DeviceReport.pm +++ b/lib/Conch/Controller/DeviceReport.pm @@ -62,7 +62,7 @@ sub process ($c) { my $existing_device = $c->db_devices->active->find($c->stash('device_id')); # capture information about the last report before we store the new one - # state can be: error, fail, processing, pass, where no validations on a valid report is + # state can be: error, fail, pass, where no validations on a valid report is # considered to be a pass. my ($previous_report_id, $previous_report_status); if ($existing_device) { diff --git a/lib/Conch/DB/Result/ValidationResult.pm b/lib/Conch/DB/Result/ValidationResult.pm index 6e1d5bd02..ada528fca 100644 --- a/lib/Conch/DB/Result/ValidationResult.pm +++ b/lib/Conch/DB/Result/ValidationResult.pm @@ -68,7 +68,7 @@ __PACKAGE__->table("validation_result"); =head2 status data_type: 'enum' - extra: {custom_type_name => "validation_status_enum",list => ["error","fail","processing","pass"]} + extra: {custom_type_name => "validation_status_enum",list => ["error","fail","pass"]} is_nullable: 0 =head2 category @@ -118,7 +118,7 @@ __PACKAGE__->add_columns( data_type => "enum", extra => { custom_type_name => "validation_status_enum", - list => ["error", "fail", "processing", "pass"], + list => ["error", "fail", "pass"], }, is_nullable => 0, }, @@ -227,7 +227,7 @@ __PACKAGE__->many_to_many( # Created by DBIx::Class::Schema::Loader v0.07049 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:L5ZgyNsNYfWBo+KYSmPVoQ +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:j+BVGcQVKqfsmaxGO5beRg __PACKAGE__->add_columns( '+created' => { is_serializable => 0 }, diff --git a/lib/Conch/DB/Result/ValidationState.pm b/lib/Conch/DB/Result/ValidationState.pm index 545d6d92b..d4279bda7 100644 --- a/lib/Conch/DB/Result/ValidationState.pm +++ b/lib/Conch/DB/Result/ValidationState.pm @@ -58,13 +58,13 @@ __PACKAGE__->table("validation_state"); =head2 status data_type: 'enum' - extra: {custom_type_name => "validation_status_enum",list => ["error","fail","processing","pass"]} + extra: {custom_type_name => "validation_status_enum",list => ["error","fail","pass"]} is_nullable: 0 =head2 completed data_type: 'timestamp with time zone' - is_nullable: 1 + is_nullable: 0 =head2 device_report_id @@ -99,12 +99,12 @@ __PACKAGE__->add_columns( data_type => "enum", extra => { custom_type_name => "validation_status_enum", - list => ["error", "fail", "processing", "pass"], + list => ["error", "fail", "pass"], }, is_nullable => 0, }, "completed", - { data_type => "timestamp with time zone", is_nullable => 1 }, + { data_type => "timestamp with time zone", is_nullable => 0 }, "device_report_id", { data_type => "uuid", is_foreign_key => 1, is_nullable => 0, size => 16 }, ); @@ -199,7 +199,7 @@ __PACKAGE__->many_to_many( # Created by DBIx::Class::Schema::Loader v0.07049 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:yN5z1kiYZILdKOK92ANSgA +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:IW7WIVipHk9DhkNSWWdevw __PACKAGE__->add_columns( '+created' => { retrieve_on_insert => 1 }, diff --git a/lib/Conch/ValidationSystem.pm b/lib/Conch/ValidationSystem.pm index e19cd1e5c..44d2d392a 100644 --- a/lib/Conch/ValidationSystem.pm +++ b/lib/Conch/ValidationSystem.pm @@ -365,7 +365,6 @@ sub run_validation_plan ($self, %options) { my $status = reduce { $a eq 'error' || $b eq 'error' ? 'error' : $a eq 'fail' || $b eq 'fail' ? 'fail' - : $a eq 'processing' || $b eq 'processing' ? 'processing' : $a; # pass } map $_->status, @validation_results; diff --git a/sql/migrations/0103-validation_status_enum-processing.sql b/sql/migrations/0103-validation_status_enum-processing.sql new file mode 100644 index 000000000..42fa9797f --- /dev/null +++ b/sql/migrations/0103-validation_status_enum-processing.sql @@ -0,0 +1,69 @@ +SELECT run_migration(103, $$ + + -- remove the 'processing' value from validation_status_enum: + -- this is an old state that validation_states would be initially created under, + -- and then status would be updated later, with completed=now(). + + -- transform all validation_result entries with status = 'processing' to 'error' + -- (although we do not expect there actually are any such rows) + update validation_result + set status = 'error' + where status = 'processing'; + + -- for all validation_state rows with status = 'processing', + -- use the worst status of all its result member(s). + + update validation_state set status = 'error' + from validation_state_member + left join validation_result on validation_result.id = validation_state_member.validation_result_id + where + validation_state.status = 'processing' + and validation_state_member.validation_state_id = validation_state.id + and validation_result.status = 'error'; + + update validation_state set status = 'fail' + from validation_state_member + left join validation_result on validation_result.id = validation_state_member.validation_result_id + where + validation_state.status = 'processing' + and validation_state_member.validation_state_id = validation_state.id + and validation_result.status = 'fail'; + + update validation_state set status = 'pass' + from validation_state_member + left join validation_result on validation_result.id = validation_state_member.validation_result_id + where + validation_state.status = 'processing' + and validation_state_member.validation_state_id = validation_state.id + and validation_result.status = 'pass'; + + -- now there should be no validation_state rows remaining with status = 'processing' + -- except those with no associated members at all -- the best we can do is to call + -- that result an 'error', so we can continue to preserve the associated device_report. + + update validation_state set status = 'error' where status = 'processing'; + + -- now we can safely remove 'processing' as one of the values for the enum. + + alter type validation_status_enum rename to _validation_status_enum_old; + create type validation_status_enum as enum ('error','fail','pass'); + alter table validation_result + alter column status type validation_status_enum using status::text::validation_status_enum; + alter table validation_state + alter column status type validation_status_enum using status::text::validation_status_enum; + drop type _validation_status_enum_old; + + -- also set 'completed' for all these records, and make it not-nullable. + + update validation_state + set completed = greatest(validation_state.created, device_report.created) + from device_report + where device_report.id = validation_state.device_report_id + and validation_state.completed is null; + + alter table validation_state alter completed set not null; + drop index validation_state_device_id_validation_plan_id_completed_idx; + create index validation_state_device_id_validation_plan_id_completed_idx on validation_state + (device_id, validation_plan_id, completed desc); + +$$); diff --git a/sql/schema.sql b/sql/schema.sql index bf430667b..df7caaca5 100644 --- a/sql/schema.sql +++ b/sql/schema.sql @@ -93,7 +93,6 @@ ALTER TYPE public.user_workspace_role_enum OWNER TO conch; CREATE TYPE public.validation_status_enum AS ENUM ( 'error', 'fail', - 'processing', 'pass' ); @@ -669,7 +668,7 @@ CREATE TABLE public.validation_state ( validation_plan_id uuid NOT NULL, created timestamp with time zone DEFAULT now() NOT NULL, status public.validation_status_enum NOT NULL, - completed timestamp with time zone, + completed timestamp with time zone NOT NULL, device_report_id uuid NOT NULL ); @@ -1383,7 +1382,7 @@ CREATE INDEX validation_state_device_id_idx ON public.validation_state USING btr -- Name: validation_state_device_id_validation_plan_id_completed_idx; Type: INDEX; Schema: public; Owner: conch -- -CREATE INDEX validation_state_device_id_validation_plan_id_completed_idx ON public.validation_state USING btree (device_id, validation_plan_id, completed DESC) WHERE (completed IS NOT NULL); +CREATE INDEX validation_state_device_id_validation_plan_id_completed_idx ON public.validation_state USING btree (device_id, validation_plan_id, completed DESC); -- From f1e4c2cace6caecb67f025f5c85efd3f024d69ab Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Wed, 5 Jun 2019 16:07:52 -0700 Subject: [PATCH 4/7] rename validation_result.component_id to component It is not a uuid, but just a plain old string that could contain anything. --- .../modules/Conch::DB::Result::ValidationResult.md | 2 +- docs/modules/Conch::Validation.md | 10 +++++----- json-schema/response.yaml | 4 ++-- lib/Conch/DB/Result/ValidationResult.pm | 6 +++--- lib/Conch/Validation.pm | 14 +++++++------- lib/Conch/Validation/DiskSmartStatus.pm | 2 +- lib/Conch/Validation/DiskTemperature.pm | 2 +- lib/Conch/Validation/HddSize.pm | 6 +++--- lib/Conch/Validation/SwitchPeers.pm | 2 +- lib/Conch/ValidationSystem.pm | 4 ++-- .../0104-validation_result-component.sql | 5 +++++ sql/schema.sql | 2 +- t/integration/device-reports.t | 2 +- t/integration/device-validations.t | 4 ++-- t/lib/Conch/Validation/ExternalException.pm | 2 +- t/lib/Conch/Validation/MultipleResults.pm | 4 ++-- t/lib/Conch/Validation/MutateDevice.pm | 2 +- t/validation-system/run_validations.t | 4 ++-- 18 files changed, 41 insertions(+), 36 deletions(-) create mode 100644 sql/migrations/0104-validation_result-component.sql diff --git a/docs/modules/Conch::DB::Result::ValidationResult.md b/docs/modules/Conch::DB::Result::ValidationResult.md index 01552a8f1..9c97cc4a4 100644 --- a/docs/modules/Conch::DB::Result::ValidationResult.md +++ b/docs/modules/Conch::DB::Result::ValidationResult.md @@ -72,7 +72,7 @@ data_type: 'text' is_nullable: 0 ``` -## component\_id +## component ``` data_type: 'text' diff --git a/docs/modules/Conch::Validation.md b/docs/modules/Conch::Validation.md index 4ab8822d5..cedb77d45 100644 --- a/docs/modules/Conch::Validation.md +++ b/docs/modules/Conch::Validation.md @@ -276,7 +276,7 @@ You may also provide the following attributes to override validation results attribute. This value is not stored in the database. To disambiguate multiple results in the database, use - `component_id`. + `component`. ```perl $self->register_result( @@ -314,16 +314,16 @@ You may also provide the following attributes to override validation results ); ``` -- `component_id` +- `component` - You may specify the optional string attribute `component_id` to set an + You may specify the optional string attribute `component` to set an identifier to help identify a specific component under test. ```perl $self->register_result( expected => 'OK', got => $disk->{health}, - component_id => $disk->{serial_number} + component => $disk->{serial_number} ); ``` @@ -370,7 +370,7 @@ $self->fail('This validation fails but validation evaluation will continue') unless defined($data->{required_value}); ``` -The attributes `name`, `category`, `component_id`, and `hint` may be +The attributes `name`, `category`, `component`, and `hint` may be specified like with ["register\_result"](#register_result). ```perl diff --git a/json-schema/response.yaml b/json-schema/response.yaml index d80b4f901..bf4b361d8 100644 --- a/json-schema/response.yaml +++ b/json-schema/response.yaml @@ -1034,7 +1034,7 @@ definitions: required: - id - category - - component_id + - component - hardware_product_id - hint - message @@ -1048,7 +1048,7 @@ definitions: - $ref: common.yaml#/definitions/uuid category: type: string - component_id: + component: oneOf: - type: 'null' - type: string diff --git a/lib/Conch/DB/Result/ValidationResult.pm b/lib/Conch/DB/Result/ValidationResult.pm index ada528fca..dc4ed7fb6 100644 --- a/lib/Conch/DB/Result/ValidationResult.pm +++ b/lib/Conch/DB/Result/ValidationResult.pm @@ -76,7 +76,7 @@ __PACKAGE__->table("validation_result"); data_type: 'text' is_nullable: 0 -=head2 component_id +=head2 component data_type: 'text' is_nullable: 1 @@ -124,7 +124,7 @@ __PACKAGE__->add_columns( }, "category", { data_type => "text", is_nullable => 0 }, - "component_id", + "component", { data_type => "text", is_nullable => 1 }, "result_order", { data_type => "integer", is_nullable => 0 }, @@ -227,7 +227,7 @@ __PACKAGE__->many_to_many( # Created by DBIx::Class::Schema::Loader v0.07049 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:j+BVGcQVKqfsmaxGO5beRg +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7w+LDN1uxN72P3styqzW5A __PACKAGE__->add_columns( '+created' => { is_serializable => 0 }, diff --git a/lib/Conch/Validation.pm b/lib/Conch/Validation.pm index 5bb8aae02..801a608bc 100644 --- a/lib/Conch/Validation.pm +++ b/lib/Conch/Validation.pm @@ -423,7 +423,7 @@ Validation class. You may override the validation result name with this attribute. This value is not stored in the database. To disambiguate multiple results in the database, use -C. +C. $self->register_result( expected => 'hello', @@ -455,15 +455,15 @@ attribute. category => 'BIOS' ); -=item C +=item C -You may specify the optional string attribute C to set an +You may specify the optional string attribute C to set an identifier to help identify a specific component under test. $self->register_result( expected => 'OK', got => $disk->{health}, - component_id => $disk->{serial_number} + component => $disk->{serial_number} ); =item C @@ -556,7 +556,7 @@ sub register_result ($self, %attrs) { message => $attrs{message} || $message, name => $attrs{name} || $self->name, category => $attrs{category} || $self->category, - component_id => $attrs{component_id}, + component => $attrs{component}, status => $success ? _STATUS_PASS : _STATUS_FAIL, hint => $success ? undef : $attrs{hint}, }; @@ -626,7 +626,7 @@ continue validating other parts of the data. $self->fail('This validation fails but validation evaluation will continue') unless defined($data->{required_value}); -The attributes C, C, C, and C may be +The attributes C, C, C, and C may be specified like with L. $self->fail('I fail!', @@ -641,7 +641,7 @@ sub fail ($self, $message, %attrs) { message => $message, name => $attrs{name} || $self->name, category => $attrs{category} || $self->category, - component_id => $attrs{component_id}, + component => $attrs{component}, status => _STATUS_FAIL, hint => $attrs{hint} }; diff --git a/lib/Conch/Validation/DiskSmartStatus.pm b/lib/Conch/Validation/DiskSmartStatus.pm index a93c76bba..b37a6c075 100644 --- a/lib/Conch/Validation/DiskSmartStatus.pm +++ b/lib/Conch/Validation/DiskSmartStatus.pm @@ -30,7 +30,7 @@ sub validate { $self->register_result( expected => 'OK', got => $disk->{health}, - component_id => $disk_sn + component => $disk_sn ); } } diff --git a/lib/Conch/Validation/DiskTemperature.pm b/lib/Conch/Validation/DiskTemperature.pm index 5e469890f..f4622a49f 100644 --- a/lib/Conch/Validation/DiskTemperature.pm +++ b/lib/Conch/Validation/DiskTemperature.pm @@ -33,7 +33,7 @@ sub validate { expected => $MAX_TEMP, got => $disk->{temp}, cmp => '<', - component_id => $disk_sn, + component => $disk_sn, ); } } diff --git a/lib/Conch/Validation/HddSize.pm b/lib/Conch/Validation/HddSize.pm index 1c46089f9..cd4883cd5 100644 --- a/lib/Conch/Validation/HddSize.pm +++ b/lib/Conch/Validation/HddSize.pm @@ -17,7 +17,7 @@ sub validate ($self, $data) { my $drive_model = $data->{disks}{$disk_serial}{model}; if (not $drive_model) { $self->fail('missing drive model for disk '.$disk_serial, - component_id => $disk_serial); + component => $disk_serial); next; } @@ -25,14 +25,14 @@ sub validate ($self, $data) { my $size_spec = $hw_spec->{disk_size}{$drive_model} // $hw_spec->{disk_size}{_default}; if (not $size_spec) { $self->fail('missing size specification for model '.$drive_model, - component_id => $disk_serial); + component => $disk_serial); next; } $self->register_result( got => $data->{disks}{$disk_serial}{block_sz}, expected => $size_spec, - component_id => $disk_serial, + component => $disk_serial, ); } } diff --git a/lib/Conch/Validation/SwitchPeers.pm b/lib/Conch/Validation/SwitchPeers.pm index b66de300b..ab6412338 100644 --- a/lib/Conch/Validation/SwitchPeers.pm +++ b/lib/Conch/Validation/SwitchPeers.pm @@ -73,7 +73,7 @@ sub validate { expected => [@peer_ports], got => $peer_port, cmp => 'oneOf', - component_id => $nic->{nic}, + component => $nic->{nic}, name => 'peer_ports' ); diff --git a/lib/Conch/ValidationSystem.pm b/lib/Conch/ValidationSystem.pm index 44d2d392a..6ed9257af 100644 --- a/lib/Conch/ValidationSystem.pm +++ b/lib/Conch/ValidationSystem.pm @@ -351,7 +351,7 @@ sub run_validation_plan ($self, %options) { validation_id => $validation->id, device_id => $device->id, hardware_product_id => $validator->hardware_product->id, - $_->%{qw(message hint status category component_id)}, + $_->%{qw(message hint status category component)}, }), $validator->validation_results; } @@ -419,7 +419,7 @@ sub run_validation ($self, %options) { validation_id => $validation->id, device_id => $device->id, hardware_product_id => $validator->hardware_product->id, - $_->%{qw(message hint status category component_id)}, + $_->%{qw(message hint status category component)}, }), $validator->validation_results; diff --git a/sql/migrations/0104-validation_result-component.sql b/sql/migrations/0104-validation_result-component.sql new file mode 100644 index 000000000..de6f00a9c --- /dev/null +++ b/sql/migrations/0104-validation_result-component.sql @@ -0,0 +1,5 @@ +SELECT run_migration(104, $$ + + alter table validation_result rename column component_id to component; + +$$); diff --git a/sql/schema.sql b/sql/schema.sql index df7caaca5..75955ba0f 100644 --- a/sql/schema.sql +++ b/sql/schema.sql @@ -650,7 +650,7 @@ CREATE TABLE public.validation_result ( hint text, status public.validation_status_enum NOT NULL, category text NOT NULL, - component_id text, + component text, result_order integer NOT NULL, created timestamp with time zone DEFAULT now() NOT NULL ); diff --git a/t/integration/device-reports.t b/t/integration/device-reports.t index 88e7f57c0..d7c85bdd5 100644 --- a/t/integration/device-reports.t +++ b/t/integration/device-reports.t @@ -80,7 +80,7 @@ subtest 'run report without an existing device' => sub { id => undef, validation_id => $_->id, category => $_->module->category, - component_id => ignore, + component => ignore, hardware_product_id => $hardware_product->id, hint => ignore, message => ignore, diff --git a/t/integration/device-validations.t b/t/integration/device-validations.t index de58d3eb9..df73c72ec 100644 --- a/t/integration/device-validations.t +++ b/t/integration/device-validations.t @@ -148,7 +148,7 @@ $t->get_ok('/device/TEST/validation_state') id => re(Conch::UUID::UUID_FORMAT), hardware_product_id => $device->hardware_product_id, validation_id => $validation->id, - component_id => undef, + component => undef, message => 'faked failure', hint => 'boo', status => 'fail', @@ -186,7 +186,7 @@ $t->get_ok('/device/TEST/validation_state?status=error') id => re(Conch::UUID::UUID_FORMAT), hardware_product_id => $device->hardware_product_id, validation_id => re(Conch::UUID::UUID_FORMAT), - component_id => undef, + component => undef, message => 'Missing \'product_name\' property', hint => ignore, status => 'error', diff --git a/t/lib/Conch/Validation/ExternalException.pm b/t/lib/Conch/Validation/ExternalException.pm index f325abac7..0fa03d956 100644 --- a/t/lib/Conch/Validation/ExternalException.pm +++ b/t/lib/Conch/Validation/ExternalException.pm @@ -13,7 +13,7 @@ sub validate ($self, $data) { $self->register_result( got => $got, expected => 'hi', - component_id => 'x', + component => 'x', hint => 'we should have died before getting here', ); } diff --git a/t/lib/Conch/Validation/MultipleResults.pm b/t/lib/Conch/Validation/MultipleResults.pm index 001027d08..4e7bd00ea 100644 --- a/t/lib/Conch/Validation/MultipleResults.pm +++ b/t/lib/Conch/Validation/MultipleResults.pm @@ -12,7 +12,7 @@ sub validate ($self, $data) { $self->register_result( got => 'hi', expected => 'hi', - component_id => 'x', + component => 'x', hint => 'this is ignored', ); $self->register_result( @@ -21,7 +21,7 @@ sub validate ($self, $data) { name => 'new name', message => 'new message', category => 'new category', - component_id => 'y', + component => 'y', hint => 'stfu', ); } diff --git a/t/lib/Conch/Validation/MutateDevice.pm b/t/lib/Conch/Validation/MutateDevice.pm index b95557139..82152bdea 100644 --- a/t/lib/Conch/Validation/MutateDevice.pm +++ b/t/lib/Conch/Validation/MutateDevice.pm @@ -16,7 +16,7 @@ sub validate ($self, $data) { $self->register_result( got => 'hi', expected => 'hi', - component_id => 'x', + component => 'x', hint => 'we should have died before getting here', ); } diff --git a/t/validation-system/run_validations.t b/t/validation-system/run_validations.t index 385a7bef8..778605c16 100644 --- a/t/validation-system/run_validations.t +++ b/t/validation-system/run_validations.t @@ -187,7 +187,7 @@ subtest run_validation => sub { status => 'pass', message => "Expected eq 'hi'. Got 'hi'.", category => 'multi', - component_id => 'x', + component => 'x', hint => undef, ), methods( @@ -195,7 +195,7 @@ subtest run_validation => sub { status => 'fail', message => 'new message', # override category => 'new category', # override - component_id => 'y', + component => 'y', hint => 'stfu', ), ], From 428c3b537937ef08ed02552c816d6da8bddfbfb7 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Wed, 5 Jun 2019 14:26:35 -0700 Subject: [PATCH 5/7] move rack_unit from hardware_product_profile to hardware_product Now, all hardware_product_profile columns are used only for validations. At the same time, we can normalize its name to 'rack_unit_size'. --- .../Conch::DB::Result::HardwareProduct.md | 7 ++++++ ...nch::DB::Result::HardwareProductProfile.md | 7 ------ json-schema/request.yaml | 6 ++--- json-schema/response.yaml | 6 ++--- lib/Conch/Controller/Rack.pm | 5 ++-- lib/Conch/Controller/RackLayout.pm | 20 ++++------------ lib/Conch/Controller/WorkspaceRack.pm | 4 ++-- lib/Conch/DB/Result/HardwareProduct.pm | 9 +++++++- lib/Conch/DB/Result/HardwareProductProfile.pm | 9 +------- lib/Conch/DB/ResultSet/Rack.pm | 4 ++-- lib/Conch/DB/ResultSet/RackLayout.pm | 4 ++-- lib/Test/Conch/Fixtures.pm | 8 +++---- .../0105-hardware_product-rack_size.sql | 18 +++++++++++++++ sql/schema.sql | 5 ++-- t/integration/crud/hardware-product.t | 23 +++++++++++-------- .../Validation/TestConchValidationTester.pm | 2 +- t/validation-system/test-conch-validation.t | 4 ++-- 17 files changed, 77 insertions(+), 64 deletions(-) create mode 100644 sql/migrations/0105-hardware_product-rack_size.sql diff --git a/docs/modules/Conch::DB::Result::HardwareProduct.md b/docs/modules/Conch::DB::Result::HardwareProduct.md index a7a5867d4..afb3688af 100644 --- a/docs/modules/Conch::DB::Result::HardwareProduct.md +++ b/docs/modules/Conch::DB::Result::HardwareProduct.md @@ -100,6 +100,13 @@ data_type: 'text' is_nullable: 1 ``` +## rack\_unit\_size + +``` +data_type: 'integer' +is_nullable: 0 +``` + # PRIMARY KEY - ["id"](#id) diff --git a/docs/modules/Conch::DB::Result::HardwareProductProfile.md b/docs/modules/Conch::DB::Result::HardwareProductProfile.md index 37545900e..c7fb1b3cc 100644 --- a/docs/modules/Conch::DB::Result::HardwareProductProfile.md +++ b/docs/modules/Conch::DB::Result::HardwareProductProfile.md @@ -26,13 +26,6 @@ is_nullable: 0 size: 16 ``` -## rack\_unit - -``` -data_type: 'integer' -is_nullable: 0 -``` - ## purpose ``` diff --git a/json-schema/request.yaml b/json-schema/request.yaml index c82005ba7..6f920db21 100644 --- a/json-schema/request.yaml +++ b/json-schema/request.yaml @@ -208,6 +208,7 @@ definitions: - name - alias - hardware_vendor_id + - rack_unit_size - type: object properties: hardware_product_profile: @@ -217,8 +218,6 @@ definitions: additionalProperties: false minProperties: 1 properties: - rack_unit: - $ref: common.yaml#/definitions/positive_integer purpose: type: string bios_firmware: @@ -335,13 +334,14 @@ definitions: oneOf: - type: string - type: 'null' + rack_unit_size: + $ref: common.yaml#/definitions/positive_integer hardware_product_profile: $ref: /definitions/HardwareProductProfileUpdate HardwareProductProfileCreate: allOf: - $ref: /definitions/HardwareProductProfileUpdate - required: - - rack_unit - purpose - bios_firmware - cpu_num diff --git a/json-schema/response.yaml b/json-schema/response.yaml index bf4b361d8..70b707370 100644 --- a/json-schema/response.yaml +++ b/json-schema/response.yaml @@ -702,6 +702,7 @@ definitions: - legacy_product_name - sku - specification + - rack_unit_size - hardware_product_profile - created - updated @@ -735,6 +736,8 @@ definitions: oneOf: - type: string - type: 'null' + rack_unit_size: + $ref: common.yaml#/definitions/positive_integer hardware_product_profile: oneOf: - $ref: /definitions/HardwareProductProfile @@ -758,7 +761,6 @@ definitions: - nics_num - psu_total - purpose - - rack_unit - ram_total - sas_hdd_num - sas_hdd_size @@ -800,8 +802,6 @@ definitions: - type: 'null' purpose: type: string - rack_unit: - $ref: common.yaml#/definitions/positive_integer ram_total: type: integer sas_hdd_num: diff --git a/lib/Conch/Controller/Rack.pm b/lib/Conch/Controller/Rack.pm index b4644495a..a030b41f7 100644 --- a/lib/Conch/Controller/Rack.pm +++ b/lib/Conch/Controller/Rack.pm @@ -199,14 +199,13 @@ sub get_assignment ($c) { ->search(undef, { join => [ { device_location => 'device' }, - { hardware_product => 'hardware_product_profile' }, + 'hardware_product', ], '+columns' => { device_id => 'device.id', device_asset_tag => 'device.asset_tag', hardware_product_name => 'hardware_product.name', - # TODO: this should be renamed in the db itself. - rack_unit_size => 'hardware_product_profile.rack_unit', + rack_unit_size => 'hardware_product.rack_unit_size', }, collapse => 1, }) diff --git a/lib/Conch/Controller/RackLayout.pm b/lib/Conch/Controller/RackLayout.pm index a67c7c544..9164924c8 100644 --- a/lib/Conch/Controller/RackLayout.pm +++ b/lib/Conch/Controller/RackLayout.pm @@ -66,11 +66,7 @@ sub create ($c) { my $new_rack_unit_size = $c->db_hardware_products ->search({ 'hardware_product.id' => $input->{hardware_product_id} }) - ->related_resultset('hardware_product_profile') - ->get_column('rack_unit')->single; - - return $c->status(409, { error => 'missing hardware product profile on hardware product id '.$input->{hardware_product_id} }) - if not $new_rack_unit_size; + ->get_column('rack_unit_size')->single; if ($input->{rack_unit_start} + $new_rack_unit_size - 1 > $rack_size) { $c->log->debug('layout ends at rack unit '.($input->{rack_unit_start} + $new_rack_unit_size - 1) @@ -182,21 +178,15 @@ sub update ($c) { # determine assigned slots, not counting the slots currently assigned to this layout (which # we will be giving up) - my $current_rack_unit_size = $c->db_hardware_products->search( - { 'hardware_product.id' => $layout->hardware_product_id }) - ->related_resultset('hardware_product_profile')->get_column('rack_unit')->single; - - return $c->status(409, { error => 'missing hardware product profile on hardware product id '.$layout->hardware_product_id }) - if not $current_rack_unit_size; + my $current_rack_unit_size = $c->db_hardware_products + ->search({ 'hardware_product.id' => $layout->hardware_product_id }) + ->get_column('rack_unit_size')->single; my $new_rack_unit_size = $input->{hardware_product_id} ? $c->db_hardware_products->search({ 'hardware_product.id' => $input->{hardware_product_id} }) - ->related_resultset('hardware_product_profile')->get_column('rack_unit')->single + ->get_column('rack_unit_size')->single : $current_rack_unit_size; - return $c->status(409, { error => 'missing hardware product profile on hardware product id '.$input->{hardware_product_id} }) - if not $new_rack_unit_size; - my $new_rack_unit_start = $input->{rack_unit_start} // $layout->rack_unit_start; if ($new_rack_unit_start + $new_rack_unit_size - 1 > $rack_size) { diff --git a/lib/Conch/Controller/WorkspaceRack.pm b/lib/Conch/Controller/WorkspaceRack.pm index 4e62c48bb..0c271fdc3 100644 --- a/lib/Conch/Controller/WorkspaceRack.pm +++ b/lib/Conch/Controller/WorkspaceRack.pm @@ -129,7 +129,7 @@ sub get_layout ($c) { 'layout.rack_unit_start' => 'rack_layouts.rack_unit_start', (map +('layout.'.$_ => 'hardware_product.'.$_), qw(alias id name)), 'layout.vendor' => 'hardware_vendor.name', - 'layout.rack_unit_size' => 'hardware_product_profile.rack_unit', + 'layout.rack_unit_size' => 'hardware_product.rack_unit_size', (map +('layout.device.'.$_ => 'device.'.$_), $c->schema->source('device')->columns), }, join => [ @@ -137,7 +137,7 @@ sub get_layout ($c) { 'datacenter_room', { rack_layouts => [ { device_location => 'device' }, - { hardware_product => [ 'hardware_vendor', 'hardware_product_profile' ] }, + { hardware_product => 'hardware_vendor' }, ] }, ], order_by => 'rack_layouts.rack_unit_start', diff --git a/lib/Conch/DB/Result/HardwareProduct.pm b/lib/Conch/DB/Result/HardwareProduct.pm index a77ef5678..aa3361e15 100644 --- a/lib/Conch/DB/Result/HardwareProduct.pm +++ b/lib/Conch/DB/Result/HardwareProduct.pm @@ -96,6 +96,11 @@ __PACKAGE__->table("hardware_product"); data_type: 'text' is_nullable: 1 +=head2 rack_unit_size + + data_type: 'integer' + is_nullable: 0 + =cut __PACKAGE__->add_columns( @@ -138,6 +143,8 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 1 }, "legacy_product_name", { data_type => "text", is_nullable => 1 }, + "rack_unit_size", + { data_type => "integer", is_nullable => 0 }, ); =head1 PRIMARY KEY @@ -231,7 +238,7 @@ __PACKAGE__->has_many( # Created by DBIx::Class::Schema::Loader v0.07049 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:0hTIkj6YBJs9YfiYJ0dKog +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:uAGpzIKHGyPai0IfNRmrRg use experimental 'signatures'; diff --git a/lib/Conch/DB/Result/HardwareProductProfile.pm b/lib/Conch/DB/Result/HardwareProductProfile.pm index e08dacdc5..443aa8086 100644 --- a/lib/Conch/DB/Result/HardwareProductProfile.pm +++ b/lib/Conch/DB/Result/HardwareProductProfile.pm @@ -42,11 +42,6 @@ __PACKAGE__->table("hardware_product_profile"); is_nullable: 0 size: 16 -=head2 rack_unit - - data_type: 'integer' - is_nullable: 0 - =head2 purpose data_type: 'text' @@ -208,8 +203,6 @@ __PACKAGE__->add_columns( }, "hardware_product_id", { data_type => "uuid", is_foreign_key => 1, is_nullable => 0, size => 16 }, - "rack_unit", - { data_type => "integer", is_nullable => 0 }, "purpose", { data_type => "text", is_nullable => 0 }, "bios_firmware", @@ -328,7 +321,7 @@ __PACKAGE__->belongs_to( # Created by DBIx::Class::Schema::Loader v0.07049 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:A0d1Pmyg3nXXBUIx/wf1oA +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:gCQaYu/NdLtRe78u+a+1QA __PACKAGE__->add_columns( '+hardware_product_id' => { is_serializable => 0 }, diff --git a/lib/Conch/DB/ResultSet/Rack.pm b/lib/Conch/DB/ResultSet/Rack.pm index c7bded47a..c20d96ccb 100644 --- a/lib/Conch/DB/ResultSet/Rack.pm +++ b/lib/Conch/DB/ResultSet/Rack.pm @@ -30,9 +30,9 @@ sub assigned_rack_units ($self) { my @layout_data = $self->search_related('rack_layouts', undef, { columns => { rack_unit_start => 'rack_layouts.rack_unit_start', - rack_unit_size => 'hardware_product_profile.rack_unit', + rack_unit_size => 'hardware_product.rack_unit_size', }, - join => { hardware_product => 'hardware_product_profile' }, + join => 'hardware_product', order_by => 'rack_unit_start', })->hri->all; diff --git a/lib/Conch/DB/ResultSet/RackLayout.pm b/lib/Conch/DB/ResultSet/RackLayout.pm index 954e90d63..02db173be 100644 --- a/lib/Conch/DB/ResultSet/RackLayout.pm +++ b/lib/Conch/DB/ResultSet/RackLayout.pm @@ -23,8 +23,8 @@ Chainable resultset that adds C to the results. sub with_rack_unit_size ($self) { $self->search(undef, { - join => { hardware_product => 'hardware_product_profile' }, - '+columns' => { rack_unit_size => 'hardware_product_profile.rack_unit' }, + join => 'hardware_product', + '+columns' => { rack_unit_size => 'hardware_product.rack_unit_size' }, collapse => 1, }); } diff --git a/lib/Test/Conch/Fixtures.pm b/lib/Test/Conch/Fixtures.pm index d6a3cd715..5d4e81931 100644 --- a/lib/Test/Conch/Fixtures.pm +++ b/lib/Test/Conch/Fixtures.pm @@ -149,6 +149,7 @@ my %canned_definitions = ( alias => 'Switch Vendor', prefix => 'F10', legacy_product_name => 'FuerzaDiaz', + rack_unit_size => 1, }, requires => { hardware_vendor_0 => { our => 'hardware_vendor_id', their => 'id' }, @@ -164,6 +165,7 @@ my %canned_definitions = ( sku => '550-551-001', generation_name => 'Joyent-G1', legacy_product_name => 'Joyent-Compute-Platform', + rack_unit_size => 2, }, requires => { hardware_vendor_0 => { our => 'hardware_vendor_id', their => 'id' }, @@ -179,6 +181,7 @@ my %canned_definitions = ( sku => '550-552-003', generation_name => 'Joyent-S1', legacy_product_name => 'Joyent-Storage-Platform', + rack_unit_size => 4, }, requires => { hardware_vendor_1 => { our => 'hardware_vendor_id', their => 'id' }, @@ -196,7 +199,6 @@ my %canned_definitions = ( ram_total => 3, nics_num => 48, psu_total => 2, - rack_unit => 1, usb_num => 0, }, requires => { @@ -219,7 +221,6 @@ my %canned_definitions = ( sata_ssd_size => 93, sata_ssd_slots => '0', psu_total => 2, - rack_unit => 4, usb_num => 1, }, requires => { @@ -242,7 +243,6 @@ my %canned_definitions = ( sata_ssd_size => 93, sata_ssd_slots => '0', psu_total => 2, - rack_unit => 2, usb_num => 1, }, requires => { @@ -555,6 +555,7 @@ sub _generate_definition ($self, $fixture_type, $num, $specification) { using => { name => "hardware_product_$num", alias => "hardware_product_$num", + rack_unit_size => 42, ($specification // {})->%*, }, requires => { @@ -569,7 +570,6 @@ sub _generate_definition ($self, $fixture_type, $num, $specification) { "hardware_product_profile_$num" => { new => 'hardware_product_profile', using => { - rack_unit => 42, purpose => 'none', bios_firmware => 'none', cpu_num => 0, diff --git a/sql/migrations/0105-hardware_product-rack_size.sql b/sql/migrations/0105-hardware_product-rack_size.sql new file mode 100644 index 000000000..4f9f3d7ec --- /dev/null +++ b/sql/migrations/0105-hardware_product-rack_size.sql @@ -0,0 +1,18 @@ +SELECT run_migration(105, $$ + + alter table hardware_product + add column rack_unit_size integer check (rack_unit_size > 0); + + update hardware_product + set rack_unit_size = hardware_product_profile.rack_unit + from hardware_product_profile + where hardware_product_profile.hardware_product_id = hardware_product.id; + + -- for the remaining rows, use a obviously-placeholder value, to be fixed later (the large + -- rack unit size will prevent any layouts from using this hardware without fixing) + update hardware_product set rack_unit_size = 999 where rack_unit_size is null; + + alter table hardware_product alter rack_unit_size set not null; + alter table hardware_product_profile drop column rack_unit; + +$$); diff --git a/sql/schema.sql b/sql/schema.sql index 75955ba0f..a8ca0abf0 100644 --- a/sql/schema.sql +++ b/sql/schema.sql @@ -370,7 +370,9 @@ CREATE TABLE public.hardware_product ( specification jsonb, sku text, generation_name text, - legacy_product_name text + legacy_product_name text, + rack_unit_size integer NOT NULL, + CONSTRAINT hardware_product_rack_unit_size_check CHECK ((rack_unit_size > 0)) ); @@ -383,7 +385,6 @@ ALTER TABLE public.hardware_product OWNER TO conch; CREATE TABLE public.hardware_product_profile ( id uuid DEFAULT public.gen_random_uuid() NOT NULL, hardware_product_id uuid NOT NULL, - rack_unit integer NOT NULL, purpose text NOT NULL, bios_firmware text NOT NULL, hba_firmware text, diff --git a/t/integration/crud/hardware-product.t b/t/integration/crud/hardware-product.t index 906264b62..7e9bb0586 100644 --- a/t/integration/crud/hardware-product.t +++ b/t/integration/crud/hardware-product.t @@ -41,6 +41,7 @@ $t->post_ok('/hardware_product', json => { name => 'sungo', hardware_vendor_id => $vendor_id, alias => 'sungo', + rack_unit_size => 2, }) ->status_is(303); @@ -59,6 +60,7 @@ $t->get_ok($t->tx->res->headers->location) sku => undef, generation_name => undef, legacy_product_name => undef, + rack_unit_size => 2, hardware_product_profile => undef, }); @@ -74,6 +76,7 @@ $t->post_ok('/hardware_product', json => { name => 'sungo', hardware_vendor_id => $vendor_id, alias => 'sungo', + rack_unit_size => 1, }) ->status_is(409) ->json_schema_is('Error') @@ -106,14 +109,13 @@ my $new_hw_profile; subtest 'create profile on existing product' => sub { $t->post_ok("/hardware_product/$new_hw_id", json => { - hardware_product_profile => { rack_unit => 1 }, + hardware_product_profile => { bios_firmware => 'foo' }, }) ->status_is(400) ->json_schema_is('RequestValidationError') ->json_cmp_deeply('/details', array_each(superhashof({ message => re(qr/missing property/i) }))); $new_hw_profile = { - rack_unit => 2, purpose => 'because', bios_firmware => 'kittens', cpu_num => 2, @@ -145,15 +147,16 @@ subtest 'update some fields in an existing profile and product' => sub { $t->post_ok("/hardware_product/$new_hw_id", json => { name => 'ether1', + rack_unit_size => 4, hardware_product_profile => { - rack_unit => 3, + dimms_num => 3, psu_total => undef, }, }) ->status_is(303); - $new_product->@{qw(name updated)} = ('ether1',re(qr/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3,9}Z$/)); - $new_product->{hardware_product_profile}->@{qw(rack_unit psu_total)} = (3,undef); + $new_product->@{qw(name rack_unit_size updated)} = ('ether1',4,re(qr/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3,9}Z$/)); + $new_product->{hardware_product_profile}->@{qw(dimms_num psu_total)} = (3,undef); $t->get_ok("/hardware_product/$new_hw_id") ->status_is(200) @@ -167,7 +170,7 @@ subtest 'create a new hardware_product_profile in an existing product' => sub { $t->post_ok("/hardware_product/$new_hw_id", json => { hardware_product_profile => { - rack_unit => 1, + dimms_num => 2, }, }) ->status_is(400) @@ -178,7 +181,7 @@ subtest 'create a new hardware_product_profile in an existing product' => sub { json => { hardware_product_profile => $new_hw_profile }) ->status_is(303); - $new_product->{hardware_product_profile}->@{qw(id rack_unit psu_total)} = (re(Conch::UUID::UUID_FORMAT),2,1); + $new_product->{hardware_product_profile}->@{qw(id dimms_num psu_total)} = (re(Conch::UUID::UUID_FORMAT),4,1); $t->get_ok("/hardware_product/$new_hw_id") ->status_is(200) @@ -194,14 +197,14 @@ subtest 'create a hardware product and hardware product profile all together' => name => 'ether2', hardware_vendor_id => $vendor_id, alias => 'ether', - hardware_product_profile => { rack_unit => 1 }, + rack_unit_size => 1, + hardware_product_profile => { dimms_num => 2 }, }) ->status_is(400) ->json_schema_is('RequestValidationError') ->json_cmp_deeply('/details', array_each({ path => re(qr{^/hardware_product_profile/}), message => re(qr/missing property/i) })); $new_hw_profile = { - rack_unit => 2, purpose => 'because', bios_firmware => 'kittens', cpu_num => 2, @@ -217,6 +220,7 @@ subtest 'create a hardware product and hardware product profile all together' => name => 'ether2', hardware_vendor_id => $vendor_id, alias => 'ether', + rack_unit_size => 2, hardware_product_profile => $new_hw_profile, }) ->status_is(303); @@ -236,6 +240,7 @@ subtest 'create a hardware product and hardware product profile all together' => sku => undef, generation_name => undef, legacy_product_name => undef, + rack_unit_size => 2, hardware_product_profile => { $new_hw_profile->%*, id => re(Conch::UUID::UUID_FORMAT), diff --git a/t/lib/Conch/Validation/TestConchValidationTester.pm b/t/lib/Conch/Validation/TestConchValidationTester.pm index dde403d39..59779d6ef 100644 --- a/t/lib/Conch/Validation/TestConchValidationTester.pm +++ b/t/lib/Conch/Validation/TestConchValidationTester.pm @@ -102,7 +102,7 @@ sub _hardware_product_profile_inflation ($self, $data) { $self->hardware_product->hardware_product_profile, methods( id => re(Conch::UUID::UUID_FORMAT), - $data->{hardware_product_profile_rack_unit} ? ( rack_unit => $data->{hardware_product_profile_rack_unit} ) : (), + $data->{hardware_product_profile_dimms_num} ? ( dimms_num => $data->{hardware_product_profile_dimms_num} ) : (), in_storage => bool(1), ), ), diff --git a/t/validation-system/test-conch-validation.t b/t/validation-system/test-conch-validation.t index 6d1a74a5e..dfe9873ee 100644 --- a/t/validation-system/test-conch-validation.t +++ b/t/validation-system/test-conch-validation.t @@ -103,7 +103,7 @@ subtest 'database object construction' => sub { test_validation( 'Conch::Validation::TestConchValidationTester', hardware_product => { - hardware_product_profile => { rack_unit => 4 }, + hardware_product_profile => { dimms_num => 4 }, }, cases => [ { @@ -118,7 +118,7 @@ subtest 'database object construction' => sub { }, { description => 'hardware_product_profile inflation', - data => { subname => '_hardware_product_profile_inflation', hardware_product_profile_rack_unit => 4 }, + data => { subname => '_hardware_product_profile_inflation', hardware_product_profile_dimms_num => 4 }, success_num => 2, }, { From 10987e0e7c99c0a2807be1a42ddfb50d26c91269 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Wed, 5 Jun 2019 15:43:13 -0700 Subject: [PATCH 6/7] add some more value constraints to the database --- sql/migrations/0106-integer-constraints.sql | 24 +++++++++++++++++++++ sql/schema.sql | 21 ++++++++++++------ 2 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 sql/migrations/0106-integer-constraints.sql diff --git a/sql/migrations/0106-integer-constraints.sql b/sql/migrations/0106-integer-constraints.sql new file mode 100644 index 000000000..5458fdf3b --- /dev/null +++ b/sql/migrations/0106-integer-constraints.sql @@ -0,0 +1,24 @@ +SELECT run_migration(106, $$ + + alter table migration + add constraint migration_id_check check (id >= 0); + + alter table device_location + add constraint device_location_rack_unit_start_check check (rack_unit_start > 0); + + alter table rack_layout + add constraint rack_layout_rack_unit_start_check check (rack_unit_start > 0); + + alter table rack_role + add constraint rack_role_rack_size_check check (rack_size > 0); + + alter table relay + add constraint relay_ssh_port_check check (ssh_port >= 0); + + alter table validation + add constraint validation_version_check check (version > 0); + + alter table validation_result + add constraint validation_result_result_order_check check (result_order >= 0); + +$$); diff --git a/sql/schema.sql b/sql/schema.sql index a8ca0abf0..f36389478 100644 --- a/sql/schema.sql +++ b/sql/schema.sql @@ -259,7 +259,8 @@ CREATE TABLE public.device_location ( rack_id uuid NOT NULL, rack_unit_start integer NOT NULL, created timestamp with time zone DEFAULT now() NOT NULL, - updated timestamp with time zone DEFAULT now() NOT NULL + updated timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT device_location_rack_unit_start_check CHECK ((rack_unit_start > 0)) ); @@ -440,7 +441,8 @@ ALTER TABLE public.hardware_vendor OWNER TO conch; CREATE TABLE public.migration ( id integer NOT NULL, - created timestamp with time zone DEFAULT now() + created timestamp with time zone DEFAULT now(), + CONSTRAINT migration_id_check CHECK ((id >= 0)) ); @@ -475,7 +477,8 @@ CREATE TABLE public.rack_layout ( hardware_product_id uuid NOT NULL, rack_unit_start integer NOT NULL, created timestamp with time zone DEFAULT now() NOT NULL, - updated timestamp with time zone DEFAULT now() NOT NULL + updated timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT rack_layout_rack_unit_start_check CHECK ((rack_unit_start > 0)) ); @@ -490,7 +493,8 @@ CREATE TABLE public.rack_role ( name text NOT NULL, rack_size integer NOT NULL, created timestamp with time zone DEFAULT now() NOT NULL, - updated timestamp with time zone DEFAULT now() NOT NULL + updated timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT rack_role_rack_size_check CHECK ((rack_size > 0)) ); @@ -508,7 +512,8 @@ CREATE TABLE public.relay ( ssh_port integer, deactivated timestamp with time zone, created timestamp with time zone DEFAULT now() NOT NULL, - updated timestamp with time zone DEFAULT now() NOT NULL + updated timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT relay_ssh_port_check CHECK ((ssh_port >= 0)) ); @@ -605,7 +610,8 @@ CREATE TABLE public.validation ( module text NOT NULL, created timestamp with time zone DEFAULT now() NOT NULL, updated timestamp with time zone DEFAULT now() NOT NULL, - deactivated timestamp with time zone + deactivated timestamp with time zone, + CONSTRAINT validation_version_check CHECK ((version > 0)) ); @@ -653,7 +659,8 @@ CREATE TABLE public.validation_result ( category text NOT NULL, component text, result_order integer NOT NULL, - created timestamp with time zone DEFAULT now() NOT NULL + created timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT validation_result_result_order_check CHECK ((result_order >= 0)) ); From 8a624e5853b39af7fae56ff5e20f9b342043aeff Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Fri, 28 Jun 2019 09:27:25 -0700 Subject: [PATCH 7/7] drop useless user_workspace_role constraint --- .../Conch::DB::Result::UserWorkspaceRole.md | 8 ------- lib/Conch/DB/Result/UserWorkspaceRole.pm | 23 +------------------ .../0107-user_workspace_role_unique.sql | 6 +++++ sql/schema.sql | 8 ------- 4 files changed, 7 insertions(+), 38 deletions(-) create mode 100644 sql/migrations/0107-user_workspace_role_unique.sql diff --git a/docs/modules/Conch::DB::Result::UserWorkspaceRole.md b/docs/modules/Conch::DB::Result::UserWorkspaceRole.md index 2cba4da6c..56094b5e7 100644 --- a/docs/modules/Conch::DB::Result::UserWorkspaceRole.md +++ b/docs/modules/Conch::DB::Result::UserWorkspaceRole.md @@ -40,14 +40,6 @@ is_nullable: 0 - ["user\_id"](#user_id) - ["workspace\_id"](#workspace_id) -# UNIQUE CONSTRAINTS - -## `user_workspace_role_user_id_workspace_id_role_key` - -- ["user\_id"](#user_id) -- ["workspace\_id"](#workspace_id) -- ["role"](#role) - # RELATIONS ## user\_account diff --git a/lib/Conch/DB/Result/UserWorkspaceRole.pm b/lib/Conch/DB/Result/UserWorkspaceRole.pm index 92a88304a..49aeb6116 100644 --- a/lib/Conch/DB/Result/UserWorkspaceRole.pm +++ b/lib/Conch/DB/Result/UserWorkspaceRole.pm @@ -82,27 +82,6 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("user_id", "workspace_id"); -=head1 UNIQUE CONSTRAINTS - -=head2 C - -=over 4 - -=item * L - -=item * L - -=item * L - -=back - -=cut - -__PACKAGE__->add_unique_constraint( - "user_workspace_role_user_id_workspace_id_role_key", - ["user_id", "workspace_id", "role"], -); - =head1 RELATIONS =head2 user_account @@ -137,7 +116,7 @@ __PACKAGE__->belongs_to( # Created by DBIx::Class::Schema::Loader v0.07049 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:C9QntnAPTnpmIVzf6eU4Ow +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ou3awMImfudGc6HMnEfdlQ =head2 role_cmp diff --git a/sql/migrations/0107-user_workspace_role_unique.sql b/sql/migrations/0107-user_workspace_role_unique.sql new file mode 100644 index 000000000..98ac3c5fd --- /dev/null +++ b/sql/migrations/0107-user_workspace_role_unique.sql @@ -0,0 +1,6 @@ +SELECT run_migration(107, $$ + + -- this constraint serves no purpose. the primary key already covers this. + alter table user_workspace_role drop constraint user_workspace_role_user_id_workspace_id_role_key; + +$$); diff --git a/sql/schema.sql b/sql/schema.sql index f36389478..22b594d0f 100644 --- a/sql/schema.sql +++ b/sql/schema.sql @@ -969,14 +969,6 @@ ALTER TABLE ONLY public.user_workspace_role ADD CONSTRAINT user_workspace_role_pkey PRIMARY KEY (user_id, workspace_id); --- --- Name: user_workspace_role user_workspace_role_user_id_workspace_id_role_key; Type: CONSTRAINT; Schema: public; Owner: conch --- - -ALTER TABLE ONLY public.user_workspace_role - ADD CONSTRAINT user_workspace_role_user_id_workspace_id_role_key UNIQUE (user_id, workspace_id, role); - - -- -- Name: validation validation_name_version_key; Type: CONSTRAINT; Schema: public; Owner: conch --