Validate NOT NULL constraints for project_id in x509 tables

Summary

Validate the NOT NULL constraints for project_id columns in x509_issuers and x509_certificates tables that were previously added in NOT VALID state.

Background

NOT NULL constraints were added to these tables in !207072 (merged) with validate: false. This created the constraints in a NOT VALID state, which doesn't enforce the constraint on existing data. We need to validate these constraints to ensure full data integrity.

Implementation

Create post-deployment migrations to validate the existing NOT VALID constraints:

  • Validate x509_certificates.project_id NOT NULL constraint
  • Validate x509_issuers.project_id NOT NULL constraint

Additionally, update the model associations to reflect that project is required (optional: false).

Acceptance Criteria

  • NOT NULL constraint validated for x509_certificates.project_id
  • NOT NULL constraint validated for x509_issuers.project_id
  • Model associations updated to belongs_to :project, optional: false
  • Tests updated to verify required associations
  • Database schema updated to show constraints as valid

Related

Edited by Vasilii Iakliushin