fix(mysql): fix domain_expiry migration for MySQL 8.0 compatibility (#6612)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: CommanderStorm <26258709+CommanderStorm@users.noreply.github.com>
This commit is contained in:
Copilot
2026-01-06 21:41:04 +01:00
committed by GitHub
parent 8d11807f77
commit 82c6b364af
5 changed files with 141 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ const { describe, test } = require("node:test");
const fs = require("fs");
const path = require("path");
const { GenericContainer, Wait } = require("testcontainers");
const { MySqlContainer } = require("@testcontainers/mysql");
describe("Database Migration", () => {
test("SQLite migrations run successfully from fresh database", async () => {
@@ -130,4 +131,68 @@ describe("Database Migration", () => {
}
}
);
test(
"MySQL migrations run successfully from fresh database",
{
skip:
!!process.env.CI &&
(process.platform !== "linux" || process.arch !== "x64"),
},
async () => {
// Start MySQL 8.0 container (the version mentioned in the issue)
const mysqlContainer = await new MySqlContainer("mysql:8.0")
.withStartupTimeout(120000)
.start();
const knex = require("knex");
const knexInstance = knex({
client: "mysql2",
connection: {
host: mysqlContainer.getHost(),
port: mysqlContainer.getPort(),
user: mysqlContainer.getUsername(),
password: mysqlContainer.getUserPassword(),
database: mysqlContainer.getDatabase(),
connectTimeout: 60000,
},
pool: {
min: 0,
max: 10,
acquireTimeoutMillis: 60000,
idleTimeoutMillis: 60000,
},
});
// Setup R (redbean) with knex instance like production code does
const { R } = require("redbean-node");
R.setup(knexInstance);
try {
// Use production code to initialize MySQL tables
const { createTables } = require("../../db/knex_init_db.js");
await createTables();
// Run all migrations like production code does
await R.knex.migrate.latest({
directory: path.join(__dirname, "../../db/knex_migrations")
});
// Test passes if migrations complete successfully without errors
} finally {
// Clean up
try {
await R.knex.destroy();
} catch (e) {
// Ignore cleanup errors
}
try {
await mysqlContainer.stop();
} catch (e) {
// Ignore cleanup errors
}
}
}
);
});