Skip to content

Commit

Permalink
fix(migration): include context source, target columns
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Apr 18, 2021
1 parent 3fd2201 commit 3017aff
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/entity/Context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,13 @@ export class Context extends BaseEntity implements ContextOptions {

public parser?: Parser;

@Column('simple-json')
public source: ServiceMetadata;

@Column('simple-json')
public sourceUser: ContextUser;

@Column('simple-json')
public target?: ServiceMetadata;

public token?: Token;
Expand Down
15 changes: 15 additions & 0 deletions src/migration/0001618702349-ContextUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm';
import { TABLE_CONTEXT } from '../entity/Context';
import { COLUMN_NAME, COLUMN_UID } from './0001544311178-CreateContext';

const COLUMN_SOURCE = new TableColumn({
name: 'source',
type: 'varchar',
});

const COLUMN_TARGET= new TableColumn({
default: null,
name: 'target',
type: 'varchar',
});

const COLUMN_USER = new TableColumn({
name: 'sourceUser',
type: 'varchar',
Expand All @@ -14,9 +25,13 @@ export class ContextUser0001618702349 implements MigrationInterface {
await query.dropColumn(TABLE_CONTEXT, 'uid');

await query.addColumn(TABLE_CONTEXT, COLUMN_USER);
await query.addColumn(TABLE_CONTEXT, COLUMN_SOURCE);
await query.addColumn(TABLE_CONTEXT, COLUMN_TARGET);
}

public async down(query: QueryRunner): Promise<void> {
await query.dropColumn(TABLE_CONTEXT, COLUMN_TARGET);
await query.dropColumn(TABLE_CONTEXT, COLUMN_SOURCE);
await query.dropColumn(TABLE_CONTEXT, COLUMN_USER);

await query.addColumn(TABLE_CONTEXT, new TableColumn(COLUMN_NAME));
Expand Down

0 comments on commit 3017aff

Please sign in to comment.