hexabot/api/src/migration/migration.schema.ts

33 lines
1.3 KiB
TypeScript
Raw Normal View History

2025-01-02 07:34:33 +00:00
/*
* Copyright © 2025 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/
2025-01-03 15:39:55 +00:00
import { ModelDefinition, Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { LifecycleHookManager } from '@/utils/generics/lifecycle-hook-manager';
import { THydratedDocument } from '@/utils/types/filter.types';
2025-01-02 07:34:33 +00:00
2025-01-05 09:14:39 +00:00
import { MigrationAction, MigrationVersion } from './types';
2025-01-02 07:34:33 +00:00
@Schema({ timestamps: true })
export class Migration {
@Prop({ type: String, required: true, unique: true })
2025-01-05 09:14:39 +00:00
version: MigrationVersion;
2025-01-02 07:34:33 +00:00
2025-01-05 08:29:36 +00:00
@Prop({ type: String, required: true, enum: Object.values(MigrationAction) })
2025-01-03 15:39:55 +00:00
status: MigrationAction;
2025-01-02 07:34:33 +00:00
}
2025-01-03 15:39:55 +00:00
export const MigrationModel: ModelDefinition = LifecycleHookManager.attach({
name: Migration.name,
schema: SchemaFactory.createForClass(Migration),
});
2025-01-02 07:34:33 +00:00
2025-01-03 15:39:55 +00:00
export default MigrationModel.schema;
2025-01-02 07:34:33 +00:00
2025-01-03 15:39:55 +00:00
export type MigrationDocument = THydratedDocument<Migration>;