Skip to content

Commit

Permalink
add rename for mysql version 5.7
Browse files Browse the repository at this point in the history
  • Loading branch information
invisal committed Oct 14, 2024
1 parent 858ae12 commit ef127bc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/connections/mysql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,13 @@ export class MySQLConnection extends SqlConnection {
);

if (!columnLine) return;
const [columnNamePart, ...columnDefinitions] =
columnLine.split(' ');
const [columnNamePart, ...columnDefinitions] = columnLine
.trim()
.replace(/,$/, '')
.split(' ');

const query = `ALTER TABLE ${fullTableName} CHANGE ${columnNamePart} ${this.dialect.escapeId(newColumnName)} ${columnDefinitions.join(' ')}`;
const query = `ALTER TABLE ${fullTableName} CHANGE COLUMN ${columnNamePart} ${this.dialect.escapeId(newColumnName)} ${columnDefinitions.join(' ')}`;
console.log(query);
await this.query({ query });
}

Expand Down

0 comments on commit ef127bc

Please sign in to comment.