/**
 * Allow NULL in self_hosted_licenses.max_health_checks_per_month to mean "unlimited".
 *
 * Paid self-hosted licenses (auto-minted after a Razorpay payment) carry no
 * per-month health-check cap — the limit is intentionally not enforced. The
 * column was created NOT NULL DEFAULT 100, which forced a bogus cap onto every
 * paid key. Drop NOT NULL (and the default) so createLicense() can store NULL.
 *
 * Idempotent: DROP NOT NULL / DROP DEFAULT are no-ops if already applied.
 */
module.exports = {
  name: 'licenses_nullable_health_checks',
  up: async (client) => {
    await client.query(`
      ALTER TABLE self_hosted_licenses
        ALTER COLUMN max_health_checks_per_month DROP NOT NULL;
    `);
    await client.query(`
      ALTER TABLE self_hosted_licenses
        ALTER COLUMN max_health_checks_per_month DROP DEFAULT;
    `);
  },
};
