ci: Fix mysql tests (no-changelog) (#11799)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2024-11-20 09:56:14 +01:00 committed by GitHub
parent 10991675fe
commit e1dacb4d57
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 25 additions and 37 deletions

View file

@ -1,18 +1,12 @@
version: '3.9'
services:
mysql:
image: mysql:5.7
mariadb:
image: mariadb:10.9
environment:
- MYSQL_DATABASE=n8n
- MYSQL_ROOT_PASSWORD=password
- MARIADB_DATABASE=n8n
- MARIADB_ROOT_PASSWORD=password
- MARIADB_MYSQL_LOCALHOST_USER=true
ports:
- 3306:3306
ulimits:
nproc: 65535
nofile:
soft: 26677
hard: 46677
postgres:
image: postgres:16

View file

@ -8,6 +8,7 @@ on:
paths:
- packages/cli/src/databases/**
- .github/workflows/ci-postgres-mysql.yml
- .github/docker-compose.yml
pull_request_review:
types: [submitted]
@ -71,8 +72,8 @@ jobs:
working-directory: packages/cli
run: pnpm jest
mysql:
name: MySQL
mariadb:
name: MariaDB
runs-on: ubuntu-latest
needs: build
timeout-minutes: 20
@ -96,16 +97,16 @@ jobs:
path: ./packages/**/dist
key: ${{ github.sha }}:db-tests
- name: Start MySQL
- name: Start MariaDB
uses: isbang/compose-action@v2.0.0
with:
compose-file: ./.github/docker-compose.yml
services: |
mysql
mariadb
- name: Test MySQL
- name: Test MariaDB
working-directory: packages/cli
run: pnpm test:mysql --testTimeout 20000
run: pnpm test:mariadb --testTimeout 20000
postgres:
name: Postgres
@ -147,7 +148,7 @@ jobs:
notify-on-failure:
name: Notify Slack on failure
runs-on: ubuntu-latest
needs: [mysql, postgres]
needs: [mariadb, postgres]
steps:
- name: Notify Slack on failure
uses: act10ns/slack@v2.0.0
@ -156,4 +157,4 @@ jobs:
status: ${{ job.status }}
channel: '#alerts-build'
webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
message: Postgres or MySQL tests failed (${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
message: Postgres or MariaDB tests failed (${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})

View file

@ -28,7 +28,7 @@
"test:dev": "N8N_LOG_LEVEL=silent DB_TYPE=sqlite jest --watch",
"test:sqlite": "N8N_LOG_LEVEL=silent DB_TYPE=sqlite jest",
"test:postgres": "N8N_LOG_LEVEL=silent DB_TYPE=postgresdb DB_POSTGRESDB_SCHEMA=alt_schema DB_TABLE_PREFIX=test_ jest --no-coverage",
"test:mysql": "N8N_LOG_LEVEL=silent DB_TYPE=mysqldb DB_TABLE_PREFIX=test_ jest --no-coverage",
"test:mariadb": "N8N_LOG_LEVEL=silent DB_TYPE=mariadb DB_TABLE_PREFIX=test_ jest --no-coverage",
"watch": "tsc-watch -p tsconfig.build.json --onCompilationComplete \"tsc-alias -p tsconfig.build.json\""
},
"bin": {

View file

@ -29,7 +29,7 @@ export class MigrateIntegerKeysToString1690000000001 implements IrreversibleMigr
);
await queryRunner.query(`UPDATE ${tablePrefix}workflow_entity SET id = CONVERT(tmp_id, CHAR);`);
await queryRunner.query(
`CREATE INDEX \`TMP_idx_${tablePrefix}workflow_entity_id\` ON ${tablePrefix}workflow_entity (\`id\`);`,
`CREATE UNIQUE INDEX \`TMP_idx_${tablePrefix}workflow_entity_id\` ON ${tablePrefix}workflow_entity (\`id\`);`,
);
await queryRunner.query(
@ -40,7 +40,7 @@ export class MigrateIntegerKeysToString1690000000001 implements IrreversibleMigr
);
await queryRunner.query(`UPDATE ${tablePrefix}tag_entity SET id = CONVERT(tmp_id, CHAR);`);
await queryRunner.query(
`CREATE INDEX \`TMP_idx_${tablePrefix}tag_entity_id\` ON ${tablePrefix}tag_entity (\`id\`);`,
`CREATE UNIQUE INDEX \`TMP_idx_${tablePrefix}tag_entity_id\` ON ${tablePrefix}tag_entity (\`id\`);`,
);
await queryRunner.query(
@ -65,7 +65,7 @@ export class MigrateIntegerKeysToString1690000000001 implements IrreversibleMigr
`ALTER TABLE ${tablePrefix}workflows_tags DROP PRIMARY KEY, ADD PRIMARY KEY (\`workflowId\`, \`tagId\`);`,
);
await queryRunner.query(
`CREATE INDEX \`idx_${tablePrefix}workflows_tags_workflowid\` ON ${tablePrefix}workflows_tags (\`workflowId\`);`,
`CREATE INDEX \`idx_${tablePrefix}workflows_tags_workflow_id\` ON ${tablePrefix}workflows_tags (\`workflowId\`);`,
);
await queryRunner.query(
`ALTER TABLE ${tablePrefix}workflows_tags DROP FOREIGN KEY \`FK_${tablePrefix}54b2f0343d6a2078fa137443869\`;`,
@ -207,7 +207,7 @@ export class MigrateIntegerKeysToString1690000000001 implements IrreversibleMigr
`UPDATE ${tablePrefix}credentials_entity SET id = CONVERT(tmp_id, CHAR);`,
);
await queryRunner.query(
`CREATE INDEX \`TMP_idx_${tablePrefix}credentials_entity_id\` ON ${tablePrefix}credentials_entity (\`id\`);`,
`CREATE UNIQUE INDEX \`TMP_idx_${tablePrefix}credentials_entity_id\` ON ${tablePrefix}credentials_entity (\`id\`);`,
);
await queryRunner.query(
@ -259,7 +259,7 @@ export class MigrateIntegerKeysToString1690000000001 implements IrreversibleMigr
`UPDATE ${tablePrefix}variables SET \`id\` = CONVERT(\`tmp_id\`, CHAR);`,
);
await queryRunner.query(
`CREATE INDEX \`TMP_idx_${tablePrefix}variables_id\` ON ${tablePrefix}variables (\`id\`);`,
`CREATE UNIQUE INDEX \`TMP_idx_${tablePrefix}variables_id\` ON ${tablePrefix}variables (\`id\`);`,
);
await queryRunner.query(
`ALTER TABLE ${tablePrefix}variables CHANGE \`tmp_id\` \`tmp_id\` int NOT NULL;`,
@ -268,5 +268,8 @@ export class MigrateIntegerKeysToString1690000000001 implements IrreversibleMigr
`ALTER TABLE ${tablePrefix}variables DROP PRIMARY KEY, ADD PRIMARY KEY (\`id\`);`,
);
await queryRunner.query(`ALTER TABLE ${tablePrefix}variables DROP COLUMN \`tmp_id\`;`);
await queryRunner.query(
`DROP INDEX \`TMP_idx_${tablePrefix}variables_id\` ON ${tablePrefix}variables;`,
);
}
}

View file

@ -15,18 +15,8 @@ export class LicenseMetricsRepository extends Repository<LicenseMetrics> {
}
toTableName(name: string) {
const tablePrefix = this.globalConfig.database.tablePrefix;
let tableName =
this.globalConfig.database.type === 'mysqldb'
? `\`${tablePrefix}${name}\``
: `"${tablePrefix}${name}"`;
const pgSchema = this.globalConfig.database.postgresdb.schema;
if (pgSchema !== 'public') tableName = [pgSchema, tablePrefix + name].join('.');
return tableName;
const { tablePrefix } = this.globalConfig.database;
return this.manager.connection.driver.escape(`${tablePrefix}${name}`);
}
async getLicenseRenewalMetrics() {