mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 22:59:07 +00:00
refactor: Add unit column to metrics table and improve code readability in StatementGenerator.ts
This commit is contained in:
parent
e762778fc6
commit
d954b4a5df
@ -58,7 +58,7 @@ const DataMigrations: Array<DataMigrationBase> = [
|
||||
new GenerateNewCertsForStatusPage(),
|
||||
new AddEndDateToMonitorStatusTimelineWhereEndDateIsMissing(),
|
||||
new RemoveCanFromPermissions(),
|
||||
new AddUnitColumnToMetricsTable()
|
||||
new AddUnitColumnToMetricsTable(),
|
||||
];
|
||||
|
||||
export default DataMigrations;
|
||||
|
@ -597,8 +597,14 @@ export default class StatementGenerator<TBaseModel extends AnalyticsBaseModel> {
|
||||
columns
|
||||
.append(keyStatement)
|
||||
.append(SQL` `)
|
||||
.append(column.required ? this.toColumnType(column.type): (SQL`Nullable(`.append(this.toColumnType(column.type)).append(SQL`)`)));
|
||||
|
||||
.append(
|
||||
column.required
|
||||
? this.toColumnType(column.type)
|
||||
: SQL`Nullable(`
|
||||
.append(this.toColumnType(column.type))
|
||||
.append(SQL`)`)
|
||||
);
|
||||
|
||||
if (nestedModelColumns) {
|
||||
columns.append(SQL` `).append(nestedModelColumns);
|
||||
}
|
||||
@ -659,7 +665,9 @@ export default class StatementGenerator<TBaseModel extends AnalyticsBaseModel> {
|
||||
const statement: Statement = SQL`
|
||||
ALTER TABLE ${this.database.getDatasourceOptions().database!}.${
|
||||
this.model.tableName
|
||||
} ADD COLUMN IF NOT EXISTS `.append(this.toColumnsCreateStatement([column], false));
|
||||
} ADD COLUMN IF NOT EXISTS `.append(
|
||||
this.toColumnsCreateStatement([column], false)
|
||||
);
|
||||
|
||||
logger.debug(`${this.model.tableName} Add Column Statement`);
|
||||
logger.debug(statement);
|
||||
|
Loading…
Reference in New Issue
Block a user