Skip to content

Commit 76c6303

Browse files
committed
Add debugging for MySQL connection issue
- Test direct MySQL connection from host - Log environment variables being set (masked) - Help diagnose why mysqldef can't connect
1 parent a5b066e commit 76c6303

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

.github/workflows/example.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ jobs:
8080
done
8181
# Create the test database
8282
docker exec $(docker compose ps -q mysql) mysql -uroot -e "CREATE DATABASE testdb;"
83+
# Test connection from host
84+
echo "Testing connection from host..."
85+
mysql -h localhost -P 3306 -u root -e "SHOW DATABASES;" || echo "Direct connection failed, but that's OK if mysqldef can connect"
8386
8487
- name: Preview MySQL schema changes
8588
uses: ./

dist/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,18 @@ async function run() {
337337
const baselineConfig = { ...config };
338338
baselineConfig.args = baselineConfig.args.map((arg) => (arg === schemaFile ? actualBaselineFile : arg));
339339
core.info("Applying baseline schema to database");
340+
// Debug: Log environment variables being set
341+
if (baselineConfig.env) {
342+
const sanitizedEnv = { ...baselineConfig.env };
343+
// Mask any password values for security
344+
if ('MYSQL_PWD' in sanitizedEnv) {
345+
sanitizedEnv.MYSQL_PWD = sanitizedEnv.MYSQL_PWD ? '***' : '(empty)';
346+
}
347+
if ('PGPASSWORD' in sanitizedEnv) {
348+
sanitizedEnv.PGPASSWORD = sanitizedEnv.PGPASSWORD ? '***' : '(empty)';
349+
}
350+
core.debug(`Environment variables: ${JSON.stringify(sanitizedEnv)}`);
351+
}
340352
try {
341353
await runSqldef(binaryPath, baselineConfig);
342354
}

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,18 @@ async function run(): Promise<void> {
339339
baselineConfig.args = baselineConfig.args.map((arg) => (arg === schemaFile ? actualBaselineFile : arg));
340340

341341
core.info("Applying baseline schema to database");
342+
// Debug: Log environment variables being set
343+
if (baselineConfig.env) {
344+
const sanitizedEnv = { ...baselineConfig.env };
345+
// Mask any password values for security
346+
if ("MYSQL_PWD" in sanitizedEnv) {
347+
sanitizedEnv.MYSQL_PWD = sanitizedEnv.MYSQL_PWD ? "***" : "(empty)";
348+
}
349+
if ("PGPASSWORD" in sanitizedEnv) {
350+
sanitizedEnv.PGPASSWORD = sanitizedEnv.PGPASSWORD ? "***" : "(empty)";
351+
}
352+
core.debug(`Environment variables: ${JSON.stringify(sanitizedEnv)}`);
353+
}
342354
try {
343355
await runSqldef(binaryPath, baselineConfig);
344356
} catch (error) {

0 commit comments

Comments
 (0)