Skip to content

Commit

Permalink
Merge branch 'develop' into fix/project-module-table
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmbabhazi committed Feb 15, 2025
2 parents 5003514 + 5f04ccb commit 0e74466
Show file tree
Hide file tree
Showing 12 changed files with 949 additions and 108 deletions.
25 changes: 18 additions & 7 deletions packages/contracts/src/lib/reaction.model.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
import { IBasePerTenantAndOrganizationEntityModel, ID } from './base-entity.model';
import { IUser } from './user.model';
import { ActorTypeEnum, IBasePerTenantAndOrganizationEntityModel, ID, OmitFields } from './base-entity.model';
import { IEmployeeEntityInput } from './employee.model';

export interface IReaction extends IBasePerTenantAndOrganizationEntityModel {
/**
* Reaction entity interface
*/
export interface IReaction extends IBasePerTenantAndOrganizationEntityModel, IEmployeeEntityInput {
entity: ReactionEntityEnum;
entityId: ID; // Indicate the ID of entity record reaction related to
emoji: string;
creator?: IUser;
creatorId?: ID; // The reaction's employee author ID
actorType?: ActorTypeEnum; // Will be stored as 0 or 1 in DB
}

/**
* Reaction entity enum
*/
export enum ReactionEntityEnum {
Comment = 'Comment',
Task = 'Task'
}

export interface IReactionCreateInput extends Omit<IReaction, 'creatorId'> {}
/**
* Reaction create input interface
*/
export interface IReactionCreateInput extends OmitFields<IReaction, 'employee' | 'employeeId'> {}

export interface IReactionUpdateInput extends Pick<IReaction, 'emoji'> {}
/**
* Reaction update input interface
*/
export interface IReactionUpdateInput extends IBasePerTenantAndOrganizationEntityModel, Pick<IReaction, 'emoji'> {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import * as chalk from 'chalk';
import { DatabaseTypeEnum } from '@gauzy/config';

export class AlterReactionTableUsingEmployeeId1739264215793 implements MigrationInterface {
name = 'AlterReactionTableUsingEmployeeId1739264215793';

/**
* Up Migration
*
* @param queryRunner
*/
public async up(queryRunner: QueryRunner): Promise<void> {
console.log(chalk.yellow(this.name + ' start running!'));

switch (queryRunner.connection.options.type) {
case DatabaseTypeEnum.sqlite:
case DatabaseTypeEnum.betterSqlite3:
await this.sqliteUpQueryRunner(queryRunner);
break;
case DatabaseTypeEnum.postgres:
await this.postgresUpQueryRunner(queryRunner);
break;
case DatabaseTypeEnum.mysql:
await this.mysqlUpQueryRunner(queryRunner);
break;
default:
throw Error(`Unsupported database: ${queryRunner.connection.options.type}`);
}
}

/**
* Down Migration
*
* @param queryRunner
*/
public async down(queryRunner: QueryRunner): Promise<void> {
switch (queryRunner.connection.options.type) {
case DatabaseTypeEnum.sqlite:
case DatabaseTypeEnum.betterSqlite3:
await this.sqliteDownQueryRunner(queryRunner);
break;
case DatabaseTypeEnum.postgres:
await this.postgresDownQueryRunner(queryRunner);
break;
case DatabaseTypeEnum.mysql:
await this.mysqlDownQueryRunner(queryRunner);
break;
default:
throw Error(`Unsupported database: ${queryRunner.connection.options.type}`);
}
}

/**
* PostgresDB Up Migration
*
* @param queryRunner
*/
public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise<any> {}

/**
* PostgresDB Down Migration
*
* @param queryRunner
*/
public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise<any> {}

/**
* SqliteDB and BetterSQlite3DB Up Migration
*
* @param queryRunner
*/
public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise<any> {}

/**
* SqliteDB and BetterSQlite3DB Down Migration
*
* @param queryRunner
*/
public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise<any> {}

/**
* MySQL Up Migration
*
* @param queryRunner
*/
public async mysqlUpQueryRunner(queryRunner: QueryRunner): Promise<any> {}

/**
* MySQL Down Migration
*
* @param queryRunner
*/
public async mysqlDownQueryRunner(queryRunner: QueryRunner): Promise<any> {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@ export class AlterCommentEntityTable1739364133493 implements MigrationInterface
await queryRunner.query(`ALTER TABLE "comment" RENAME TO "temporary_comment"`);

// Step 3: Create a new "comment" table with the old schema.
// This new table includes "creatorId" and "resolvedById" with their foreign key constraints.
console.log('Step 3: Creating new "comment" table with old schema (with "creatorId" and "resolvedById")...');
await queryRunner.query(`
CREATE TABLE "comment" (
Expand Down
Loading

0 comments on commit 0e74466

Please sign in to comment.