Convert metadata tables to camelCase (#2400)
* Convert metadata tables to camelCase * datasourcemetadataid to datasourceid * refactor metadata folders * fix command * move commands out of metadata * fix seed * rename objectId and fieldId in objectMetadataId and fieldMetadataId in FE * fix field-metadata * Fix * Fix * remove logs --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import {
|
||||
TenantMigrationColumnActionType,
|
||||
TenantMigrationTableAction,
|
||||
} from 'src/metadata/tenant-migration/tenant-migration.entity';
|
||||
TenantMigrationColumnActionType,
|
||||
} from 'src/database/typeorm/metadata/entities/tenant-migration.entity';
|
||||
|
||||
export const addCompanyTable: TenantMigrationTableAction[] = [
|
||||
{
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import {
|
||||
TenantMigrationColumnActionType,
|
||||
TenantMigrationTableAction,
|
||||
} from 'src/metadata/tenant-migration/tenant-migration.entity';
|
||||
TenantMigrationColumnActionType,
|
||||
} from 'src/database/typeorm/metadata/entities/tenant-migration.entity';
|
||||
|
||||
export const addViewTable: TenantMigrationTableAction[] = [
|
||||
{
|
||||
@ -18,7 +18,7 @@ export const addViewTable: TenantMigrationTableAction[] = [
|
||||
action: TenantMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'objectId',
|
||||
columnName: 'objectMetadataId',
|
||||
columnType: 'varchar',
|
||||
action: TenantMigrationColumnActionType.CREATE,
|
||||
},
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import {
|
||||
TenantMigrationColumnActionType,
|
||||
TenantMigrationTableAction,
|
||||
} from 'src/metadata/tenant-migration/tenant-migration.entity';
|
||||
TenantMigrationColumnActionType,
|
||||
} from 'src/database/typeorm/metadata/entities/tenant-migration.entity';
|
||||
|
||||
export const addViewFieldTable: TenantMigrationTableAction[] = [
|
||||
{
|
||||
@ -13,7 +13,7 @@ export const addViewFieldTable: TenantMigrationTableAction[] = [
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'fieldId',
|
||||
columnName: 'fieldMetadataId',
|
||||
columnType: 'varchar',
|
||||
action: TenantMigrationColumnActionType.CREATE,
|
||||
},
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import {
|
||||
TenantMigrationColumnActionType,
|
||||
TenantMigrationTableAction,
|
||||
} from 'src/metadata/tenant-migration/tenant-migration.entity';
|
||||
TenantMigrationColumnActionType,
|
||||
} from 'src/database/typeorm/metadata/entities/tenant-migration.entity';
|
||||
|
||||
export const addViewFilterTable: TenantMigrationTableAction[] = [
|
||||
{
|
||||
@ -13,7 +13,7 @@ export const addViewFilterTable: TenantMigrationTableAction[] = [
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'fieldId',
|
||||
columnName: 'fieldMetadataId',
|
||||
columnType: 'varchar',
|
||||
action: TenantMigrationColumnActionType.CREATE,
|
||||
},
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import {
|
||||
TenantMigrationColumnActionType,
|
||||
TenantMigrationTableAction,
|
||||
} from 'src/metadata/tenant-migration/tenant-migration.entity';
|
||||
TenantMigrationColumnActionType,
|
||||
} from 'src/database/typeorm/metadata/entities/tenant-migration.entity';
|
||||
|
||||
export const addViewSortTable: TenantMigrationTableAction[] = [
|
||||
{
|
||||
@ -13,7 +13,7 @@ export const addViewSortTable: TenantMigrationTableAction[] = [
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'fieldId',
|
||||
columnName: 'fieldMetadataId',
|
||||
columnType: 'varchar',
|
||||
action: TenantMigrationColumnActionType.CREATE,
|
||||
},
|
||||
|
||||
@ -1,57 +0,0 @@
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
export enum TenantMigrationColumnActionType {
|
||||
CREATE = 'CREATE',
|
||||
RELATION = 'RELATION',
|
||||
}
|
||||
|
||||
export type TenantMigrationColumnCreate = {
|
||||
action: TenantMigrationColumnActionType.CREATE;
|
||||
columnName: string;
|
||||
columnType: string;
|
||||
};
|
||||
|
||||
export type TenantMigrationColumnRelation = {
|
||||
action: TenantMigrationColumnActionType.RELATION;
|
||||
columnName: string;
|
||||
referencedTableName: string;
|
||||
referencedTableColumnName: string;
|
||||
};
|
||||
|
||||
export type TenantMigrationColumnAction = {
|
||||
action: TenantMigrationColumnActionType;
|
||||
} & (TenantMigrationColumnCreate | TenantMigrationColumnRelation);
|
||||
|
||||
export type TenantMigrationTableAction = {
|
||||
name: string;
|
||||
action: 'create' | 'alter';
|
||||
columns?: TenantMigrationColumnAction[];
|
||||
};
|
||||
@Entity('tenant_migrations')
|
||||
export class TenantMigration {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column({ nullable: true, type: 'jsonb' })
|
||||
migrations: TenantMigrationTableAction[];
|
||||
|
||||
@Column({ nullable: true })
|
||||
name: string;
|
||||
|
||||
@Column({ default: false })
|
||||
isCustom: boolean;
|
||||
|
||||
@Column({ nullable: true })
|
||||
appliedAt?: Date;
|
||||
|
||||
@Column()
|
||||
workspaceId: string;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt: Date;
|
||||
}
|
||||
@ -1,11 +1,12 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
|
||||
import { TenantMigrationEntity } from 'src/database/typeorm/metadata/entities/tenant-migration.entity';
|
||||
|
||||
import { TenantMigrationService } from './tenant-migration.service';
|
||||
import { TenantMigration } from './tenant-migration.entity';
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([TenantMigration], 'metadata')],
|
||||
imports: [TypeOrmModule.forFeature([TenantMigrationEntity], 'metadata')],
|
||||
exports: [TenantMigrationService],
|
||||
providers: [TenantMigrationService],
|
||||
})
|
||||
|
||||
@ -1,27 +0,0 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { getRepositoryToken } from '@nestjs/typeorm';
|
||||
|
||||
import { TenantMigrationService } from './tenant-migration.service';
|
||||
import { TenantMigration } from './tenant-migration.entity';
|
||||
|
||||
describe('TenantMigrationService', () => {
|
||||
let service: TenantMigrationService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [
|
||||
TenantMigrationService,
|
||||
{
|
||||
provide: getRepositoryToken(TenantMigration, 'metadata'),
|
||||
useValue: {},
|
||||
},
|
||||
],
|
||||
}).compile();
|
||||
|
||||
service = module.get<TenantMigrationService>(TenantMigrationService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
||||
@ -4,16 +4,17 @@ import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { IsNull, Repository } from 'typeorm';
|
||||
|
||||
import {
|
||||
TenantMigration,
|
||||
TenantMigrationEntity,
|
||||
TenantMigrationTableAction,
|
||||
} from './tenant-migration.entity';
|
||||
} from 'src/database/typeorm/metadata/entities/tenant-migration.entity';
|
||||
|
||||
import { standardMigrations } from './standard-migrations';
|
||||
|
||||
@Injectable()
|
||||
export class TenantMigrationService {
|
||||
constructor(
|
||||
@InjectRepository(TenantMigration, 'metadata')
|
||||
private readonly tenantMigrationRepository: Repository<TenantMigration>,
|
||||
@InjectRepository(TenantMigrationEntity, 'metadata')
|
||||
private readonly tenantMigrationRepository: Repository<TenantMigrationEntity>,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@ -60,7 +61,7 @@ export class TenantMigrationService {
|
||||
*/
|
||||
public async getPendingMigrations(
|
||||
workspaceId: string,
|
||||
): Promise<TenantMigration[]> {
|
||||
): Promise<TenantMigrationEntity[]> {
|
||||
return await this.tenantMigrationRepository.find({
|
||||
order: { createdAt: 'ASC' },
|
||||
where: {
|
||||
@ -79,7 +80,7 @@ export class TenantMigrationService {
|
||||
*/
|
||||
public async setAppliedAtForMigration(
|
||||
workspaceId: string,
|
||||
migration: TenantMigration,
|
||||
migration: TenantMigrationEntity,
|
||||
) {
|
||||
await this.tenantMigrationRepository.save({
|
||||
id: migration.id,
|
||||
|
||||
Reference in New Issue
Block a user