chore: use mysql2 as the package for mysql (#18503)

This commit is contained in:
Ben Irvin 2023-10-30 13:29:39 +01:00 committed by GitHub
parent 6d4417f55c
commit 3e3b3393e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 28 additions and 131 deletions

View File

@ -216,11 +216,10 @@ jobs:
if: needs.changes.outputs.backend == 'true'
runs-on: ubuntu-latest
needs: [changes, build, typescript, unit_back, unit_front]
name: '[CE] API Integration (mysql:latest, client: ${{ matrix.db_client }}, node: ${{ matrix.node }}, shard: ${{ matrix.shard }})'
name: '[CE] API Integration (mysql:latest, package: mysql2}, node: ${{ matrix.node }}, shard: ${{ matrix.shard }})'
strategy:
matrix:
node: [18, 20]
db_client: ['mysql', 'mysql2']
shard: [1/5, 2/5, 3/5, 4/5, 5/5]
services:
mysql:
@ -230,7 +229,6 @@ jobs:
MYSQL_USER: strapi
MYSQL_PASSWORD: strapi
MYSQL_DATABASE: strapi_test
MYSQL_AUTHENTICATION_PLUGIN: mysql_native_password
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
@ -250,14 +248,14 @@ jobs:
uses: ./.github/actions/run-build
- uses: ./.github/actions/run-api-tests
with:
dbOptions: '--dbclient=${{ matrix.db_client }} --dbhost=localhost --dbport=3306 --dbname=strapi_test --dbusername=strapi --dbpassword=strapi'
dbOptions: '--dbclient=mysql --dbhost=localhost --dbport=3306 --dbname=strapi_test --dbusername=strapi --dbpassword=strapi'
jestOptions: '--shard=${{ matrix.shard }}'
api_ce_sqlite:
if: needs.changes.outputs.backend == 'true'
runs-on: ubuntu-latest
needs: [changes, build, typescript, unit_back, unit_front]
name: '[CE] API Integration (sqlite, client: better-sqlite3, node: ${{ matrix.node }}, shard: ${{ matrix.shard }})'
name: '[CE] API Integration (sqlite, package: better-sqlite3, node: ${{ matrix.node }}, shard: ${{ matrix.shard }})'
strategy:
matrix:
node: [18, 20]
@ -325,14 +323,13 @@ jobs:
api_ee_mysql:
runs-on: ubuntu-latest
needs: [changes, build, typescript, unit_back, unit_front]
name: '[EE] API Integration (mysql:latest, client: ${{ matrix.db_client }}, node: ${{ matrix.node }}, shard: ${{ matrix.shard }})'
name: '[EE] API Integration (mysql:latest, package: mysql2, node: ${{ matrix.node }}, shard: ${{ matrix.shard }})'
if: needs.changes.outputs.backend == 'true' && github.event.pull_request.head.repo.full_name == github.repository && !(github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]')
env:
STRAPI_LICENSE: ${{ secrets.strapiLicense }}
strategy:
matrix:
node: [18, 20]
db_client: ['mysql', 'mysql2']
shard: [1/5, 2/5, 3/5, 4/5, 5/5]
services:
mysql:
@ -342,7 +339,6 @@ jobs:
MYSQL_USER: strapi
MYSQL_PASSWORD: strapi
MYSQL_DATABASE: strapi_test
MYSQL_AUTHENTICATION_PLUGIN: mysql_native_password
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
@ -362,7 +358,7 @@ jobs:
uses: ./.github/actions/run-build
- uses: ./.github/actions/run-api-tests
with:
dbOptions: '--dbclient=${{ matrix.db_client }} --dbhost=localhost --dbport=3306 --dbname=strapi_test --dbusername=strapi --dbpassword=strapi'
dbOptions: '--dbclient=mysql --dbhost=localhost --dbport=3306 --dbname=strapi_test --dbusername=strapi --dbpassword=strapi'
runEE: true
jestOptions: '--shard=${{ matrix.shard }}'

View File

@ -28,17 +28,6 @@ const mysql = {
},
};
const mysql2 = {
client: 'mysql2',
connection: {
database: 'strapi',
user: 'strapi',
password: 'strapi',
port: 3306,
host: 'localhost',
},
};
const mariadb = {
client: 'mysql',
connection: {
@ -52,7 +41,6 @@ const mariadb = {
const db = {
mysql,
mysql2,
sqlite,
postgres,
mariadb,

View File

@ -26,8 +26,7 @@
"@strapi/strapi": "4.14.5",
"better-sqlite3": "9.0.0",
"lodash": "4.17.21",
"mysql": "2.18.1",
"mysql2": "3.6.0",
"mysql2": "3.6.2",
"passport-google-oauth2": "0.2.0",
"pg": "8.11.1",
"react": "^18.2.0",

View File

@ -19,8 +19,7 @@
"@strapi/strapi": "4.14.5",
"better-sqlite3": "9.0.0",
"lodash": "4.17.21",
"mysql": "2.18.1",
"mysql2": "3.6.0",
"mysql2": "3.6.2",
"passport-google-oauth2": "0.2.0",
"pg": "8.11.1",
"react": "^18.2.0",

View File

@ -3,7 +3,7 @@ import type { Knex } from 'knex';
const clientMap = {
sqlite: 'better-sqlite3',
mysql: 'mysql',
mysql: 'mysql2',
postgres: 'pg',
};

View File

@ -28,10 +28,8 @@ const getDialectName = (client: unknown) => {
case 'postgres':
return 'postgres';
case 'mysql':
case 'mysql2':
return 'mysql';
case 'sqlite':
case 'sqlite-legacy':
return 'sqlite';
default:
throw new Error(`Unknown dialect ${client}`);

View File

@ -5,28 +5,6 @@ module.exports = ({ env }) => {
const connections = {
mysql: {
connection: {
connectionString: env('DATABASE_URL'),
host: env('DATABASE_HOST', 'localhost'),
port: env.int('DATABASE_PORT', 3306),
database: env('DATABASE_NAME', 'strapi'),
user: env('DATABASE_USERNAME', 'strapi'),
password: env('DATABASE_PASSWORD', 'strapi'),
ssl: env.bool('DATABASE_SSL', false) && {
key: env('DATABASE_SSL_KEY', undefined),
cert: env('DATABASE_SSL_CERT', undefined),
ca: env('DATABASE_SSL_CA', undefined),
capath: env('DATABASE_SSL_CAPATH', undefined),
cipher: env('DATABASE_SSL_CIPHER', undefined),
rejectUnauthorized: env.bool(
'DATABASE_SSL_REJECT_UNAUTHORIZED',
true
),
},
},
pool: { min: env.int('DATABASE_POOL_MIN', 2), max: env.int('DATABASE_POOL_MAX', 10) },
},
mysql2: {
connection: {
host: env('DATABASE_HOST', 'localhost'),
port: env.int('DATABASE_PORT', 3306),

View File

@ -5,28 +5,6 @@ export default ({ env }) => {
const connections = {
mysql: {
connection: {
connectionString: env('DATABASE_URL'),
host: env('DATABASE_HOST', 'localhost'),
port: env.int('DATABASE_PORT', 3306),
database: env('DATABASE_NAME', 'strapi'),
user: env('DATABASE_USERNAME', 'strapi'),
password: env('DATABASE_PASSWORD', 'strapi'),
ssl: env.bool('DATABASE_SSL', false) && {
key: env('DATABASE_SSL_KEY', undefined),
cert: env('DATABASE_SSL_CERT', undefined),
ca: env('DATABASE_SSL_CA', undefined),
capath: env('DATABASE_SSL_CAPATH', undefined),
cipher: env('DATABASE_SSL_CIPHER', undefined),
rejectUnauthorized: env.bool(
'DATABASE_SSL_REJECT_UNAUTHORIZED',
true
),
},
},
pool: { min: env.int('DATABASE_POOL_MIN', 2), max: env.int('DATABASE_POOL_MAX', 10) },
},
mysql2: {
connection: {
host: env('DATABASE_HOST', 'localhost'),
port: env.int('DATABASE_PORT', 3306),

View File

@ -45,7 +45,7 @@ export interface Configuration {
dependencies: Record<string, string>;
}
export type ClientName = 'mysql' | 'mysql2' | 'postgres' | 'sqlite';
export type ClientName = 'mysql' | 'postgres' | 'sqlite';
export interface DatabaseInfo {
client?: string;

View File

@ -1,8 +1,7 @@
import type { ClientName } from '../types';
const sqlClientModule = {
mysql: { mysql: '2.18.1' },
mysql2: { mysql2: '3.6.0' },
mysql: { mysql2: '3.6.2' },
postgres: { pg: '8.8.0' },
sqlite: { 'better-sqlite3': '9.0.0' },
};

View File

@ -33,16 +33,6 @@ const databases = {
password: 'strapi',
},
},
mysql2: {
client: 'mysql2',
connection: {
host: '127.0.0.1',
port: 3306,
database: 'strapi_test',
username: 'strapi',
password: 'strapi',
},
},
sqlite: {
client: 'sqlite',
connection: {

View File

@ -12386,13 +12386,6 @@ __metadata:
languageName: node
linkType: hard
"bignumber.js@npm:9.0.0":
version: 9.0.0
resolution: "bignumber.js@npm:9.0.0"
checksum: 7406d0d11dfdd2183e19be745f0d5913e3773ded5fbca2a310221e719f15fd8ec6b8d7991031a6081a6276a8e12e27d58ead60f73dcbb9d697ebe9e2dd0ad7e0
languageName: node
linkType: hard
"bin-check@npm:^4.1.0":
version: 4.1.0
resolution: "bin-check@npm:4.1.0"
@ -18216,8 +18209,7 @@ __metadata:
"@strapi/strapi": "npm:4.14.5"
better-sqlite3: "npm:9.0.0"
lodash: "npm:4.17.21"
mysql: "npm:2.18.1"
mysql2: "npm:3.6.0"
mysql2: "npm:3.6.2"
passport-google-oauth2: "npm:0.2.0"
pg: "npm:8.11.1"
react: "npm:^18.2.0"
@ -21903,8 +21895,7 @@ __metadata:
"@strapi/strapi": "npm:4.14.5"
better-sqlite3: "npm:9.0.0"
lodash: "npm:4.17.21"
mysql: "npm:2.18.1"
mysql2: "npm:3.6.0"
mysql2: "npm:3.6.2"
passport-google-oauth2: "npm:0.2.0"
pg: "npm:8.11.1"
react: "npm:^18.2.0"
@ -24249,9 +24240,9 @@ __metadata:
languageName: node
linkType: hard
"mysql2@npm:3.6.0":
version: 3.6.0
resolution: "mysql2@npm:3.6.0"
"mysql2@npm:3.6.2":
version: 3.6.2
resolution: "mysql2@npm:3.6.2"
dependencies:
denque: "npm:^2.1.0"
generate-function: "npm:^2.3.1"
@ -24261,19 +24252,7 @@ __metadata:
named-placeholders: "npm:^1.1.3"
seq-queue: "npm:^0.0.5"
sqlstring: "npm:^2.3.2"
checksum: 48a6b138288debe6205f51a993ad33de44641a6ed07f94eafb1ea5f7e75fb31bfc5532e5ddf5a664898f4d26d6cf3e490de7d1d343bc4824b4e08ace0bf2b508
languageName: node
linkType: hard
"mysql@npm:2.18.1":
version: 2.18.1
resolution: "mysql@npm:2.18.1"
dependencies:
bignumber.js: "npm:9.0.0"
readable-stream: "npm:2.3.7"
safe-buffer: "npm:5.1.2"
sqlstring: "npm:2.3.1"
checksum: 87d80e374717d7767d3e609f7f5e09987fa4dee208ba346ff269fffd2500719dcf2f65ac86c8e77649c3d52b86811a88e33cfd06e7e4a48cec53ecd4ac85c08d
checksum: 854240d4523913f87e28f3d810da7d0d41f743899402b9974dec165156109ab9d233540609295d3fce9e2deff09e30eb39d891a25d15ddb6ecbcfb65080458da
languageName: node
linkType: hard
@ -27710,7 +27689,18 @@ __metadata:
languageName: node
linkType: hard
"readable-stream@npm:2.3.7, readable-stream@npm:^2.0.0, readable-stream@npm:^2.0.1, readable-stream@npm:~2.3.6":
"readable-stream@npm:3, readable-stream@npm:^3.0.0, readable-stream@npm:^3.0.2, readable-stream@npm:^3.0.6, readable-stream@npm:^3.1.1, readable-stream@npm:^3.4.0, readable-stream@npm:^3.6.0":
version: 3.6.0
resolution: "readable-stream@npm:3.6.0"
dependencies:
inherits: "npm:^2.0.3"
string_decoder: "npm:^1.1.1"
util-deprecate: "npm:^1.0.1"
checksum: b80b3e6a7fafb1c79de7db541de357f4a5ee73bd70c21672f5a7c840d27bb27bdb0151e7ba2fd82c4a888df22ce0c501b0d9f3e4dfe51688876701c437d59536
languageName: node
linkType: hard
"readable-stream@npm:^2.0.0, readable-stream@npm:^2.0.1, readable-stream@npm:~2.3.6":
version: 2.3.7
resolution: "readable-stream@npm:2.3.7"
dependencies:
@ -27725,17 +27715,6 @@ __metadata:
languageName: node
linkType: hard
"readable-stream@npm:3, readable-stream@npm:^3.0.0, readable-stream@npm:^3.0.2, readable-stream@npm:^3.0.6, readable-stream@npm:^3.1.1, readable-stream@npm:^3.4.0, readable-stream@npm:^3.6.0":
version: 3.6.0
resolution: "readable-stream@npm:3.6.0"
dependencies:
inherits: "npm:^2.0.3"
string_decoder: "npm:^1.1.1"
util-deprecate: "npm:^1.0.1"
checksum: b80b3e6a7fafb1c79de7db541de357f4a5ee73bd70c21672f5a7c840d27bb27bdb0151e7ba2fd82c4a888df22ce0c501b0d9f3e4dfe51688876701c437d59536
languageName: node
linkType: hard
"readable-stream@npm:^2.2.2":
version: 2.3.8
resolution: "readable-stream@npm:2.3.8"
@ -29617,13 +29596,6 @@ __metadata:
languageName: node
linkType: hard
"sqlstring@npm:2.3.1":
version: 2.3.1
resolution: "sqlstring@npm:2.3.1"
checksum: bc09237002da7e1172098e7d47401ea0ae45c1e4b224619f7ee2905dc921321f5ccc8c5e076994890df01b4a3363b2b5ea295b7a10d32a35181ef25bad158093
languageName: node
linkType: hard
"sqlstring@npm:^2.3.2":
version: 2.3.3
resolution: "sqlstring@npm:2.3.3"