Open
Description
We have a number of columns that permit NULL
values, but don't actually have any:
-
file_events.additional
-
file_events.ip_address_id
-
journals.action
-
journals.name
-
oidc_publishers.discriminator
-
organization_events.additional
-
organization_events.ip_address_id
-
organizations.is_approved
-
pending_oidc_publishers.discriminator
-
prohibited_user_names.prohibited_by
-
project_events.additional
-
project_events.ip_address_id
-
projects.total_size
-
release_dependencies.kind
-
release_dependencies.specifier
-
release_files.filename
-
release_files.packagetype
-
release_files.python_version
-
release_files.size
-
release_files.upload_time
-
releases._pypi_ordering
-
sponsors.service
-
stripe_customers.billing_email
-
stripe_subscription_items.subscription_item_id
-
stripe_subscription_prices.price_id
-
stripe_subscription_prices.tax_behavior
-
stripe_subscription_products.product_id
-
stripe_subscription_products.tax_code
-
team_events.additional
-
team_events.ip_address_id
-
trove_classifiers.classifier
-
trove_classifiers.ordering
-
user_events.additional
-
user_events.ip_address_id
-
user_security_keys.public_key
-
user_security_keys.sign_count
-
vulnerabilities.aliases
-
vulnerabilities.details
-
vulnerabilities.fixed_in
-
vulnerabilities.link
We should determine if any of these are actually required to permit NULL
values, and migrate the rest to be non-nullable.
The above list was generated with:
DO $$
DECLARE
table_record record;
col_name text;
query int;
BEGIN
FOR table_record IN (SELECT table_name FROM information_schema.tables WHERE table_schema = 'public')
LOOP
FOR col_name IN
SELECT column_name
FROM information_schema.columns
WHERE table_name = table_record.table_name
AND is_nullable = 'YES'
LOOP
EXECUTE format('
SELECT COUNT(*)
FROM %I
WHERE %I IS NULL', table_record.table_name, col_name) INTO query;
IF query = 0 THEN
RAISE NOTICE '%.%', table_record.table_name, col_name;
END IF;
END LOOP;
END LOOP;
END $$;