mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-27 17:14:55 +00:00
feat: seed default task logos
This commit is contained in:
41
src/db/migrations/1733990253208-seeds-default-tasks-logo.ts
Normal file
41
src/db/migrations/1733990253208-seeds-default-tasks-logo.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import { Document } from '~/document/entities';
|
||||
import { DocumentType } from '~/document/enums';
|
||||
const DEFAULT_TASK_LOGOS = [
|
||||
{
|
||||
id: uuid(),
|
||||
name: 'bed-furniture',
|
||||
extension: '.jpg',
|
||||
documentType: DocumentType.DEFAULT_TASKS_LOGO,
|
||||
},
|
||||
{
|
||||
id: uuid(),
|
||||
name: 'dog',
|
||||
extension: '.jpg',
|
||||
documentType: DocumentType.DEFAULT_TASKS_LOGO,
|
||||
},
|
||||
{
|
||||
id: uuid(),
|
||||
name: 'dish-washing',
|
||||
extension: '.jpg',
|
||||
documentType: DocumentType.DEFAULT_TASKS_LOGO,
|
||||
},
|
||||
{
|
||||
id: uuid(),
|
||||
name: 'walking-the-dog',
|
||||
extension: '.jpg',
|
||||
documentType: DocumentType.DEFAULT_TASKS_LOGO,
|
||||
},
|
||||
];
|
||||
export class SeedsDefaultTasksLogo1733990253208 implements MigrationInterface {
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.manager.getRepository(Document).save(DEFAULT_TASK_LOGOS);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await DEFAULT_TASK_LOGOS.forEach(async (logo) => {
|
||||
await queryRunner.manager.getRepository(Document).delete({ name: logo.name, documentType: logo.documentType });
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -9,3 +9,4 @@ export * from './1733732021622-create-guardian-entity';
|
||||
export * from './1733748083604-create-theme-entity';
|
||||
export * from './1733750228289-seed-default-avatar';
|
||||
export * from './1733904556416-create-task-entities';
|
||||
export * from './1733990253208-seeds-default-tasks-logo';
|
||||
|
||||
Reference in New Issue
Block a user