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

Migration / Issue on 4.2.8/4.4.2 related to null settings #7656

Open
ianwallen opened this issue Jan 24, 2024 · 2 comments
Open

Migration / Issue on 4.2.8/4.4.2 related to null settings #7656

ianwallen opened this issue Jan 24, 2024 · 2 comments
Labels
bug critical Issue is critical and must be fixed in the next release db change Indicate that this work introduces a db structure change.

Comments

@ianwallen
Copy link
Contributor

Similar to issue #7459

Getting the following after upgrading to 4.2.8

Exception in extension function
  org.springframework.dao.InvalidDataAccessApiUsageException: The given id must not be
  null!; nested exception is java.lang.IllegalArgumentException: The given id must not be null!

The migration script is buggy. The following has the wrong upgrade script.

4.4 upgrade script

INSERT INTO Settings (name, value, datatype, position, internal) VALUES ('region/getmap/useGeodesicExtents', 'false', 2, 9591, 'n');

4.2 upgrade script

INSERT INTO Settings (name, value, datatype, position, internal) VALUES ('region/getmap/useGeodesicExtents', 'false', 2, 9591, 'n');

It should specify the editable and encrypted value.

INSERT INTO Settings (name, value, datatype, position, internal, editable, encrypted) VALUES ('region/getmap/useGeodesicExtents', 'false', 2, 9591, 'n', 'y', 'n');

To fix the issue you must manually do the following.

Also the editable and encrypted fields should be updated to be not - null to prevent this in the future.

SELECT * FROM settings WHERE editable IS NULL;

Returns region/getmap/useGeodesicExtents

UPDATE Settings SET editable = 'y' WHERE editable IS NULL;
@ianwallen ianwallen added bug critical Issue is critical and must be fixed in the next release db change Indicate that this work introduces a db structure change. labels Jan 24, 2024
@ianwallen ianwallen changed the title Migration / Issue on 4.2.8 related to null settings Migration / Issue on 4.2.8/4.4.2 related to null settings Jan 24, 2024
@ianwallen
Copy link
Contributor Author

@fxprunayre, @josegar74,
How did you fix this issue in the 4.2.6 release?
Currently anyone trying to upgrade to 4.2.8 and 4.4.2(have not tested) will fail due to this issue.
Is it expected that they will find this issue an apply the workaround?

@fxprunayre
Copy link
Member

So it means that we can have some databases without the proper default set for the editable column (and maybe same for internal and encrypted?)

@Column(name = "editable", nullable = false, length = 1, columnDefinition = "char default 'y'")

Something like the following would work (at least for postgres) if hibernate does not automatically set the default:

ALTER TABLE settings
    ALTER COLUMN editable SET DEFAULT 'y';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug critical Issue is critical and must be fixed in the next release db change Indicate that this work introduces a db structure change.
Projects
None yet
Development

No branches or pull requests

2 participants