Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add name_hash as nullable #9091

Merged
merged 1 commit into from
Nov 24, 2023
Merged

Conversation

kesselb
Copy link
Contributor

@kesselb kesselb commented Nov 24, 2023

Fix #9089

Otherwise the migration on pgsql don't work.

Otherwise the migration on pgsql don't work.

Signed-off-by: Daniel Kesselberg <[email protected]>
@@ -56,6 +56,11 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
$mailboxesTable->addUniqueIndex(['account_id', 'name_hash'], $indexNew);
}

$nameHashColumn = $mailboxesTable->getColumn('name_hash');
if (!$nameHashColumn->getNotnull()) {
$nameHashColumn->setNotnull(true);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure about this one.

The default is still NULL and the value is omitted on insert a not null violation is thrown.
Do we need a new default as well?

-- auto-generated definition
create table oc_mail_mailboxes
(
    id                  serial
        primary key,
    name                varchar(255)                                 not null,
    account_id          integer                                      not null,
    attributes          varchar(255) default '[]'::character varying not null,
    delimiter           varchar(1)   default NULL::character varying,
    messages            integer                                      not null,
    unseen              integer                                      not null,
    selectable          boolean      default false,
    special_use         varchar(255) default '[]'::character varying not null,
    sync_new_lock       integer,
    sync_changed_lock   integer,
    sync_vanished_lock  integer,
    sync_new_token      varchar(255) default NULL::character varying,
    sync_changed_token  varchar(255) default NULL::character varying,
    sync_vanished_token varchar(255) default NULL::character varying,
    sync_in_background  boolean      default false,
    my_acls             varchar(32)  default NULL::character varying,
    shared              boolean      default false,
    name_hash           varchar(255) default NULL::character varying not null
);

This comment was marked as resolved.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we change not from not null to null here, all rows should have their name_hash filled. And for inserts we have to make sure to always write with the hash. If we insert without, there will be an error. I think that is fine and nothing we can improve.

Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with a pg setup. Could trigger the bug with an existing account before going to the original migration. The migration passes with the changes of this PR.

Thank you 🙏

@ChristophWurst ChristophWurst merged commit 5c7e9d4 into main Nov 24, 2023
34 of 35 checks passed
@ChristophWurst ChristophWurst deleted the bug/5200/null-null-null branch November 24, 2023 21:29
@ChristophWurst
Copy link
Member

/backport to stable3.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Postgres error upgrading to v3.5.0 RC1: column "name_hash" contains null values
2 participants