MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / getRenameColumnSQL

Function getRenameColumnSQL

packages/sql/src/schema/SchemaHelper.ts:223–232  ·  view source on GitHub ↗

Returns SQL to rename a column in a table.

(tableName: string, oldColumnName: string, to: Column, schemaName?: string)

Source from the content-addressed store, hash-verified

221
222 /** Returns SQL to rename a column in a table. */
223 getRenameColumnSQL(tableName: string, oldColumnName: string, to: Column, schemaName?: string): string {
224 tableName = this.quote(tableName);
225 oldColumnName = this.quote(oldColumnName);
226 const columnName = this.quote(to.name);
227
228 const schemaReference = schemaName !== undefined && schemaName !== 'public' ? '"' + schemaName + '".' : '';
229 const tableReference = schemaReference + tableName;
230
231 return `alter table ${tableReference} rename column ${oldColumnName} to ${columnName}`;
232 }
233
234 /** Returns SQL to create an index on a table. */
235 getCreateIndexSQL(tableName: string, index: IndexDef): string {

Callers

nothing calls this directly

Calls 1

quoteMethod · 0.45

Tested by

no test coverage detected