Skip to content

Commit

Permalink
address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
netroy committed Aug 25, 2023
1 parent 3a6c207 commit 73c2167
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
5 changes: 1 addition & 4 deletions packages/cli/src/databases/entities/AbstractEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ function mixinTimestamps<T extends Constructor<{}>>(base: T) {
@Column(tsColumnOptions)
createdAt: Date;

@Column({
...tsColumnOptions,
onUpdate: timestampSyntax,
})
@Column(tsColumnOptions)
updatedAt: Date;

@BeforeUpdate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@ const additionalColumns = {
workflow_statistics: ['latestEvent'],
};

export class MigrateToTimestampZ1692207852593 implements IrreversibleMigration {
export class MigrateToTimestampTz1692207852593 implements IrreversibleMigration {
async up({ queryRunner, tablePrefix }: MigrationContext) {
const changeColumnType = async (tableName: string, columnName: string) =>
queryRunner.query(
`ALTER TABLE "${tablePrefix}${tableName}" ALTER COLUMN "${columnName}" TYPE TIMESTAMPTZ(3)`,
`ALTER TABLE "${tablePrefix}${tableName}" ALTER COLUMN "${columnName}" TYPE TIMESTAMP(3) WITH TIME ZONE`,
);

for (const tableName of tablesWithDefaultTimestamps) {
for (const columnName of defaultTimestampColumns) {
await changeColumnType(tableName, columnName);
}
}

for (const [tableName, columnNames] of Object.entries(additionalColumns)) {
for (const columnName of columnNames) {
await changeColumnType(tableName, columnName);
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/databases/migrations/postgresdb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import { RemoveResetPasswordColumns1690000000030 } from '../common/1690000000030
import { AddMissingPrimaryKeyOnExecutionData1690787606731 } from './1690787606731-AddMissingPrimaryKeyOnExecutionData';
import { CreateWorkflowNameIndex1691088862123 } from '../common/1691088862123-CreateWorkflowNameIndex';
import { AddMfaColumns1690000000030 } from './../common/1690000000040-AddMfaColumns';
import { MigrateToTimestampZ1692207852593 } from './1692207852593-MigrateToTimestampZ1692207852593';
import { MigrateToTimestampTz1692207852593 } from './1692207852593-MigrateToTimestampTz';

export const postgresMigrations: Migration[] = [
InitialMigration1587669153312,
Expand Down Expand Up @@ -90,5 +90,5 @@ export const postgresMigrations: Migration[] = [
AddMissingPrimaryKeyOnExecutionData1690787606731,
CreateWorkflowNameIndex1691088862123,
AddMfaColumns1690000000030,
MigrateToTimestampZ1692207852593,
MigrateToTimestampTz1692207852593,
];

0 comments on commit 73c2167

Please sign in to comment.