Skip to content

Commit

Permalink
fix: change date type to avoid migration silent failure
Browse files Browse the repository at this point in the history
  • Loading branch information
hexaltation committed Nov 20, 2024
1 parent 66b5aad commit 7fe8709
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 1 addition & 2 deletions app/gen-server/entity/ServiceAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ export class ServiceAccount extends BaseEntity {
@PrimaryGeneratedColumn()
public id: number;


@Column({type: String})
public description: string;

@Column({type: Date, default: Date.now()})
@Column({type: Date, nullable: false})
public endOfLife: string;

@ManyToOne(type => User)
Expand Down
8 changes: 6 additions & 2 deletions app/gen-server/migration/1730215435023-ServiceAccounts.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { MigrationInterface, QueryRunner, Table, TableColumn, TableForeignKey, TableIndex } from "typeorm";
import * as sqlUtils from "app/gen-server/sqlUtils";

export class ServiceAccounts1730215435023 implements MigrationInterface {

public async up(queryRunner: QueryRunner): Promise<any> {
const dbType = queryRunner.connection.driver.options.type;
const datetime = sqlUtils.datetime(dbType);

await queryRunner.addColumn('users', new TableColumn({
name: 'type',
type: 'varchar',
Expand All @@ -24,8 +28,8 @@ export class ServiceAccounts1730215435023 implements MigrationInterface {
},
{
name: 'endOfLife',
type: 'date',
default: 'now()',
type: datetime,
isNullable: false,
},
],
})
Expand Down

0 comments on commit 7fe8709

Please sign in to comment.