All files / src/platform/provisioning/schemas provisioning.schema.ts

0% Statements 0/22
0% Branches 0/4
100% Functions 0/0
0% Lines 0/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49                                                                                                 
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Schema as MongooseSchema } from 'mongoose';
 
@Schema({ timestamps: true, collection: 'tenant_provisioning_executions' })
export class TenantProvisioningExecution extends Document {
  @Prop({ required: true, unique: true, index: true })
  subdomain: string;
 
  @Prop({ required: true, index: true })
  ownerEmail: string;
 
  @Prop({ required: true, default: 'pending' })
  status: string; // pending, running, completed, failed, rollback_pending, rolled_back
 
  @Prop({ default: null })
  tenantId: string;
 
  @Prop({ default: null })
  ownerId: string;
 
  @Prop({ type: MongooseSchema.Types.Mixed, default: {} })
  metadata: any; // Saves registration parameters for resume/retry
}
export const TenantProvisioningExecutionSchema = SchemaFactory.createForClass(
  TenantProvisioningExecution,
);
 
@Schema({ timestamps: true, collection: 'tenant_provisioning_steps' })
export class TenantProvisioningStep extends Document {
  @Prop({ required: true, index: true })
  executionId: string;
 
  @Prop({ required: true })
  stepName: string;
 
  @Prop({ required: true, default: 'pending' })
  status: string; // pending, running, completed, failed, rolled_back
 
  @Prop({ default: null })
  error: string;
 
  @Prop({ default: null })
  completedAt: Date;
}
export const TenantProvisioningStepSchema = SchemaFactory.createForClass(
  TenantProvisioningStep,
);
TenantProvisioningStepSchema.index({ executionId: 1, stepName: 1 });