monogon-dev / monogon

The Monogon Monorepo. May contain traces of peanuts and a ✨pure Go Linux userland✨. Work in progress!
https://monogon.tech
Apache License 2.0
378 stars 9 forks source link

cloud: primary key constrain for machine_os_installation_request prevents new request with different generation #241

Closed fionera closed 1 year ago

fionera commented 1 year ago
root@crdb-public:26257/bmdb> show create table machine_os_installation_request;
            table_name            |                                                                 create_statement
----------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------
  machine_os_installation_request | CREATE TABLE public.machine_os_installation_request (
                                  |     machine_id UUID NOT NULL,
                                  |     generation INT8 NOT NULL,
                                  |     os_installation_request_raw BYTES NOT NULL,
                                  |     CONSTRAINT "primary" PRIMARY KEY (machine_id ASC),
                                  |     CONSTRAINT machine_os_installation_request_machine_id_fkey FOREIGN KEY (machine_id) REFERENCES public.machines(machine_id) ON DELETE RESTRICT
                                  | )
q3k commented 1 year ago

Are you trying to create a second OSInstallationRequest for the same machine? You can't have more than one tag of a kind per machine by design. Instead, you should be upserting a new OSInstallationRequest, ie. editing the existing one if there already is one, and inserting a new one otherwise.

fionera commented 1 year ago

Ok didnt know that we upsert. Can be closed then