-
Notifications
You must be signed in to change notification settings - Fork 23
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
Provide update script for "undelegated"? #829
Comments
If we can correct the state of old database entries, it would be nice to do so. Thinking on how we can implement this, we have the I had a look at the database used for zonemaster.fr and it seems that sometimes
So if we provide a script we need to explicitly check that at least one of the value is defined to set the test as delegated. |
It should be possible.
I guess that the logic for normalization should be used. |
I have currently this SQL script that seems to work for Postgres if that can help, update test_results set undelegated = test_results_undelegated.undelegated_bool::int
from (
select
test_results.id,
(
case when ds_filled.ds_filled is null then false else ds_filled.ds_filled end
or
case when ns_filled.ns_filled is null then false else ns_filled.ns_filled end
) as undelegated_bool
from test_results
left join (
select
count(*) > 0 as ds_filled, -- count non empty fields in objects and not array elements
id
from (
select
jd.value,
id
from
(
select json_array_elements(params->'ds_info') as ja, id
from test_results
) as s1,
json_each_text(ja) as jd
) as s2
where value is not null and value::text != ''::text
group by id
) as ds_filled on ds_filled.id = test_results.id
left join (
select
count(*) > 0 as ns_filled, -- count non empty fields in objects and not array elements
id
from (
select
jd.value,
id
from
(
select json_array_elements(params->'nameservers') as ja, id
from test_results
) as s1,
json_each_text(ja) as jd
) as s2
where value is not null and value::text != ''::text
group by id
) as ns_filled on ns_filled.id = test_results.id
) as test_results_undelegated where test_results.id = test_results_undelegated.id; |
Solved by #833 |
PR #826 updates how the database engines stores the information about delegated/undelegated test and handles the filter function in
get_test_history
. After the updates it is (probably) correctly and consistently handled on all database engines.Tests created in a MySQL or SQLite database before the update will always be treated as "undelegated". For a PostgreSQL database they will be treated as "delegated".
Should scripts be provided to migrate old databases to a corrected state? It should be noted that GUI currently does not use the filter function, but issue zonemaster/zonemaster-gui#251 suggests the functionality to be added, and the will potentially affect how old tests are presented.
If scripts are to be created, it must be done before the v2021.2 release.
The text was updated successfully, but these errors were encountered: