Skip to content

Commit

Permalink
Merge pull request #12553 from strapi/fix/mysqlDO
Browse files Browse the repository at this point in the history
Disable primary key requirement on session initialize
  • Loading branch information
alexandrebodin committed Feb 24, 2022
2 parents fb9cbc1 + 9d5ba5b commit 1efba6d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/core/database/lib/dialects/mysql/index.js
Expand Up @@ -32,6 +32,14 @@ class MysqlDialect extends Dialect {
};
}

async initialize() {
try {
await this.db.connection.raw(`set session sql_require_primary_key = 0;`);
} catch (err) {
// Ignore error due to lack of session permissions
}
}

async startSchemaUpdate() {
await this.db.connection.raw(`set foreign_key_checks = 0;`);
}
Expand Down

0 comments on commit 1efba6d

Please sign in to comment.