# Subscription Model Schema Fixes

## Problem
The production database has several fields that were not defined in the Django models, causing IntegrityErrors when creating subscription plans or payments.

## Fields Added

### Payment Model
1. `payment_date` - DateField with auto_now_add=True

### SubscriptionPlan Model
1. `plan_for` - CharField with choices (default='domestic')
2. `featured_job_slots` - IntegerField (default=0)
3. `job_post_limit` - IntegerField (default=0)
4. `resume_access` - BooleanField (default=False)
5. `access_scope` - CharField (default='basic')
6. `profile_visibility_boost` - BooleanField (default=False)

## Migrations Created
- 0019_payment_payment_date.py
- 0020_subscriptionplan_plan_for.py
- 0021_subscriptionplan_featured_job_slots.py
- 0022_subscriptionplan_job_post_limit.py
- 0023_subscriptionplan_resume_access.py
- 0024_subscriptionplan_access_scope.py

Note: Migration 0025 was created but deleted as those fields don't exist in production.

## Deployment Instructions for Production

### Step 1: Upload Files
Upload these files to your production server:
```
subscriptions/models.py
subscriptions/migrations/0019_payment_payment_date.py
subscriptions/migrations/0020_subscriptionplan_plan_for.py
subscriptions/migrations/0021_subscriptionplan_featured_job_slots.py
subscriptions/migrations/0022_subscriptionplan_job_post_limit.py
subscriptions/migrations/0023_subscriptionplan_resume_access.py
subscriptions/migrations/0024_subscriptionplan_access_scope.py
custom_admin/views/subscriptions.py
```

### Step 2: Fake All Migrations
Since these columns already exist in your production database, fake all migrations:

```bash
cd /path/to/your/project
source /path/to/virtualenv/bin/activate

# Fake all the migrations
python manage.py migrate subscriptions 0019 --fake
python manage.py migrate subscriptions 0020 --fake
python manage.py migrate subscriptions 0021 --fake
python manage.py migrate subscriptions 0022 --fake
python manage.py migrate subscriptions 0023 --fake
python manage.py migrate subscriptions 0024 --fake
```

### Step 3: Restart Application
```bash
# For Apache
sudo systemctl restart apache2

# OR for Gunicorn
sudo systemctl restart gunicorn

# OR touch wsgi file
touch config/wsgi.py
```

### Step 4: Test
1. Go to `/Managenashaajobs/subscriptions/plans/create/`
2. Try creating a new subscription plan
3. Verify no IntegrityErrors occur

## What This Fixes
- ✅ Payment date IntegrityError when Study Abroad users submit manual payments
- ✅ plan_for IntegrityError when creating subscription plans
- ✅ featured_job_slots IntegrityError when creating subscription plans
- ✅ job_post_limit IntegrityError when creating subscription plans
- ✅ resume_access IntegrityError when creating subscription plans
- ✅ access_scope IntegrityError when creating subscription plans
- ✅ profile_visibility_boost IntegrityError when creating subscription plans

## Notes
- All fields have appropriate default values
- Using `--fake` is safe because the columns already exist in production
- The Django models now match the production database schema
- No data will be lost or modified
