Skip to content

Commit

Permalink
fix(schema): fix diffing FKs in MySQL 8 (#1030)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsprw authored Nov 4, 2020
1 parent 89f2857 commit b6f31a5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/mysql-base/src/MySqlSchemaHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class MySqlSchemaHelper extends SchemaHelper {
}

getForeignKeysSQL(tableName: string, schemaName?: string): string {
return `select distinct k.constraint_name, k.column_name, k.referenced_table_name, k.referenced_column_name, c.update_rule, c.delete_rule `
return `select distinct k.constraint_name as constraint_name, k.column_name as column_name, k.referenced_table_name as referenced_table_name, k.referenced_column_name as referenced_column_name, c.update_rule as update_rule, c.delete_rule as delete_rule `
+ `from information_schema.key_column_usage k `
+ `inner join information_schema.referential_constraints c on c.constraint_name = k.constraint_name and c.table_name = '${tableName}' `
+ `where k.table_name = '${tableName}' and k.table_schema = database() and c.constraint_schema = database() and k.referenced_column_name is not null`;
Expand Down

0 comments on commit b6f31a5

Please sign in to comment.