diff --git a/db/knex_migrations/2025-09-02-0000-add-domain-expiry.js b/db/knex_migrations/2025-09-02-0000-add-domain-expiry.js index ede2e1889..b204a44d3 100644 --- a/db/knex_migrations/2025-09-02-0000-add-domain-expiry.js +++ b/db/knex_migrations/2025-09-02-0000-add-domain-expiry.js @@ -6,7 +6,9 @@ exports.up = function (knex) { .createTable("domain_expiry", (table) => { table.increments("id"); table.datetime("last_check"); - table.text("domain").unique().notNullable(); + // Use VARCHAR(255) for MySQL/MariaDB compatibility with unique constraint + // Maximum domain name length is 253 characters (255 octets on the wire) + table.string("domain", 255).unique().notNullable(); table.datetime("expiry"); table.integer("last_expiry_notification_sent").defaultTo(null); }); diff --git a/db/knex_migrations/2026-01-06-0000-fix-domain-expiry-column-type.js b/db/knex_migrations/2026-01-06-0000-fix-domain-expiry-column-type.js new file mode 100644 index 000000000..6728c5fb8 --- /dev/null +++ b/db/knex_migrations/2026-01-06-0000-fix-domain-expiry-column-type.js @@ -0,0 +1,14 @@ +// Ensure domain column is VARCHAR(255) across all database types. +// This migration ensures MySQL, SQLite, and MariaDB have consistent column type, +// even if a user installed 2.1.0-beta.0 or 2.1.0-beta.1 which had TEXT type for this column. +// Maximum domain name length is 253 characters (255 octets on the wire). +// Note: The unique constraint is already present from the original migration. +exports.up = function (knex) { + return knex.schema.alterTable("domain_expiry", function (table) { + table.string("domain", 255).notNullable().alter(); + }); +}; + +exports.down = function (knex) { + // No rollback needed - keeping VARCHAR(255) is the correct state +};