import { Schema, model } from 'mongoose';

const subscriptionSchema = new Schema({
  userId: {
    type: Schema.Types.ObjectId,
    required: true,
    ref: 'User',
  },
  plan: {
    type: String,
    required: true,
    enum: ['free', 'basic', 'premium'],
  },
  startDate: {
    type: Date,
    required: true,
  },
  endDate: {
    type: Date,
    required: true,
  },
  status: {
    type: String,
    required: true,
    enum: ['active', 'inactive', 'canceled'],
  },
  paymentMethod: {
    type: String,
    required: true,
  },
  billingCycle: {
    type: String,
    required: true,
    enum: ['monthly', 'yearly'],
  },
});

export const Subscription = model('Subscription', subscriptionSchema);