Comment 1 for bug 2048519

Revision history for this message
Jacopo Rota (r00ta) wrote (last edit ): Re: Migration during the upgrade to 3.4 stable is failing - default for column "extra" cannot be cast automatically to type jsonb

From the user's database

```
psql (14.10 (Ubuntu 14.10-0ubuntu0.22.04.1))
Type "help" for help.

maasdb=# \d maasserver_bootresourcefile;
                                         Table "public.maasserver_bootresourcefile"
     Column | Type | Collation | Nullable | Default
-----------------+--------------------------+-----------+----------+---------------------------------------------------------
 id | integer | | not null | nextval('maasserver_bootresourcefile_id_seq'::regclass)
 created | timestamp with time zone | | not null |
 updated | timestamp with time zone | | not null |
 resource_set_id | integer | | not null |
 largefile_id | integer | | not null |
 filename | character varying(255) | | not null |
 filetype | character varying(20) | | not null | 'tgz'::character varying
 extra | text | | not null | '""'::text
Indexes:
    "maasserver_bootresourcefile_pkey" PRIMARY KEY, btree (id)
    "maasserver_bootresourcefi_resource_set_id_1bdfd52f7cc6de80_uniq" UNIQUE CONSTRAINT, btree (resource_set_id, filename)
    "maasserver_bootresourcefile_largefile_id" btree (largefile_id)
    "maasserver_bootresourcefile_resource_set_id" btree (resource_set_id)
Foreign-key constraints:
    "largefile_id_refs_id_6192daf196cc0427" FOREIGN KEY (largefile_id) REFERENCES maasserver_largefile(id) DEFERRABLE INITIALLY DEFERRED
    "resource_set_id_refs_id_5740a0afd6adefa0" FOREIGN KEY (resource_set_id) REFERENCES maasserver_bootresourceset(id) DEFERRABLE INITIALLY DEFERRED

I'd say that the migration fails to cast the extra column to jsonb due to its default value '""'::text. The fix would be to specify how this column should be migrated - i.e. should should not just cast the column to jsonb.
```

However, from a plain 3.2/stable installation I could not manage to get the same default value for the column

```
ubuntu@maas-testmigration:~$ sudo maas-test-db.psql
psql (12.4)
Type "help" for help.

maasdb=# select * from ^C
maasdb=# \d maasserver_bootresourcefile;
                                         Table "public.maasserver_bootresourcefile"
     Column | Type | Collation | Nullable | Default
-----------------+--------------------------+-----------+----------+---------------------------------------------------------
 id | integer | | not null | nextval('maasserver_bootresourcefile_id_seq'::regclass)
 created | timestamp with time zone | | not null |
 updated | timestamp with time zone | | not null |
 filename | character varying(255) | | not null |
 filetype | character varying(20) | | not null |
 extra | text | | not null |
 largefile_id | integer | | not null |
 resource_set_id | integer | | not null |
```

I need to retry the following
I could not reproduce this with the following steps on ubuntu 20.04

- install postgresql-12
- install maas snap 3.2/stable
- upgrade postgresql-12 to postgresql-14
- upgrade to 3.3/stable
- upgrade to 3.4/stable

keep you posted