openforce/crm_core/migrations/0001_initial.py
2026-09-26 07:21:21 +00:00

137 lines
11 KiB
Python

# Generated by Django 4.2.30 on 2026-09-26 07:21
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('contenttypes', '0002_remove_content_type_name'),
]
operations = [
migrations.CreateModel(
name='Account',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
('account_type', models.CharField(choices=[('Prospect', 'Prospect'), ('Customer - Direct', 'Customer - Direct'), ('Customer - Channel', 'Customer - Channel'), ('Channel Partner / Reseller', 'Channel Partner / Reseller'), ('Installation Partner', 'Installation Partner'), ('Technology Partner', 'Technology Partner'), ('Other', 'Other')], default='Prospect', max_length=50)),
('industry', models.CharField(blank=True, choices=[('Technology', 'Technology'), ('Finance', 'Finance'), ('Healthcare', 'Healthcare'), ('Manufacturing', 'Manufacturing'), ('Retail', 'Retail'), ('Consulting', 'Consulting'), ('Education', 'Education'), ('Government', 'Government'), ('Media', 'Media'), ('Other', 'Other')], max_length=50, null=True)),
('annual_revenue', models.DecimalField(blank=True, decimal_places=2, max_digits=15, null=True)),
('phone', models.CharField(blank=True, max_length=40, null=True)),
('website', models.URLField(blank=True, max_length=255, null=True)),
('rating', models.CharField(blank=True, choices=[('Hot', 'Hot'), ('Warm', 'Warm'), ('Cold', 'Cold')], max_length=20, null=True)),
('billing_street', models.CharField(blank=True, max_length=255, null=True)),
('billing_city', models.CharField(blank=True, max_length=100, null=True)),
('billing_state', models.CharField(blank=True, max_length=100, null=True)),
('billing_postal_code', models.CharField(blank=True, max_length=20, null=True)),
('billing_country', models.CharField(blank=True, max_length=100, null=True)),
('shipping_street', models.CharField(blank=True, max_length=255, null=True)),
('shipping_city', models.CharField(blank=True, max_length=100, null=True)),
('shipping_state', models.CharField(blank=True, max_length=100, null=True)),
('shipping_postal_code', models.CharField(blank=True, max_length=20, null=True)),
('shipping_country', models.CharField(blank=True, max_length=100, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('owner', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='accounts', to=settings.AUTH_USER_MODEL)),
('parent_account', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='child_accounts', to='crm_core.account')),
],
options={
'ordering': ['-created_at'],
},
),
migrations.CreateModel(
name='Contact',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('first_name', models.CharField(blank=True, default='', max_length=100)),
('last_name', models.CharField(max_length=100)),
('title', models.CharField(blank=True, max_length=100, null=True)),
('department', models.CharField(blank=True, max_length=100, null=True)),
('email', models.EmailField(blank=True, max_length=254, null=True, unique=True)),
('phone', models.CharField(blank=True, max_length=40, null=True)),
('mobile_phone', models.CharField(blank=True, max_length=40, null=True)),
('lead_source', models.CharField(blank=True, choices=[('Web', 'Web'), ('Phone Inquiry', 'Phone Inquiry'), ('Partner Referral', 'Partner Referral'), ('Purchased List', 'Purchased List'), ('Other', 'Other')], max_length=50, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('account', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='contacts', to='crm_core.account')),
('owner', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='contacts', to=settings.AUTH_USER_MODEL)),
('reports_to', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='direct_reports', to='crm_core.contact')),
],
options={
'ordering': ['-created_at'],
},
),
migrations.CreateModel(
name='Opportunity',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
('stage', models.CharField(choices=[('Prospecting', 'Prospecting'), ('Qualification', 'Qualification'), ('Needs Analysis', 'Needs Analysis'), ('Value Proposition', 'Value Proposition'), ('Decision Makers', 'Decision Makers'), ('Proposal/Price Quote', 'Proposal/Price Quote'), ('Negotiation/Review', 'Negotiation/Review'), ('Closed Won', 'Closed Won'), ('Closed Lost', 'Closed Lost')], default='Prospecting', max_length=50)),
('amount', models.DecimalField(blank=True, decimal_places=2, max_digits=15, null=True)),
('probability', models.IntegerField(default=10)),
('expected_revenue', models.DecimalField(blank=True, decimal_places=2, max_digits=15, null=True)),
('close_date', models.DateField()),
('opp_type', models.CharField(blank=True, choices=[('Existing Customer - Upgrade', 'Existing Customer - Upgrade'), ('Existing Customer - Replacement', 'Existing Customer - Replacement'), ('Existing Customer - Downgrade', 'Existing Customer - Downgrade'), ('New Customer', 'New Customer')], max_length=50, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='opportunities', to='crm_core.account')),
('owner', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='opportunities', to=settings.AUTH_USER_MODEL)),
('primary_contact', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='primary_opportunities', to='crm_core.contact')),
],
options={
'ordering': ['-close_date'],
},
),
migrations.CreateModel(
name='Lead',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('first_name', models.CharField(blank=True, default='', max_length=100)),
('last_name', models.CharField(max_length=100)),
('company', models.CharField(max_length=255)),
('title', models.CharField(blank=True, max_length=100, null=True)),
('email', models.EmailField(blank=True, max_length=254, null=True)),
('phone', models.CharField(blank=True, max_length=40, null=True)),
('status', models.CharField(choices=[('New', 'New'), ('Contacted', 'Contacted'), ('Working', 'Working'), ('Qualified', 'Qualified'), ('Unqualified', 'Unqualified'), ('Converted', 'Converted')], default='New', max_length=50)),
('rating', models.CharField(blank=True, choices=[('Hot', 'Hot'), ('Warm', 'Warm'), ('Cold', 'Cold')], max_length=20, null=True)),
('is_converted', models.BooleanField(default=False)),
('converted_date', models.DateTimeField(blank=True, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('converted_account', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='converted_leads', to='crm_core.account')),
('converted_contact', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='converted_leads', to='crm_core.contact')),
('converted_opportunity', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='converted_leads', to='crm_core.opportunity')),
('owner', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='leads', to=settings.AUTH_USER_MODEL)),
],
options={
'ordering': ['-created_at'],
},
),
migrations.CreateModel(
name='Activity',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('subject', models.CharField(max_length=255)),
('activity_type', models.CharField(choices=[('Task', 'Task'), ('Call', 'Call'), ('Meeting', 'Meeting'), ('Email', 'Email')], default='Task', max_length=20)),
('status', models.CharField(choices=[('Not Started', 'Not Started'), ('In Progress', 'In Progress'), ('Completed', 'Completed'), ('Waiting on someone else', 'Waiting on someone else'), ('Deferred', 'Deferred')], default='Not Started', max_length=30)),
('priority', models.CharField(choices=[('High', 'High'), ('Normal', 'Normal'), ('Low', 'Low')], default='Normal', max_length=20)),
('due_date', models.DateField(blank=True, null=True)),
('completed_at', models.DateTimeField(blank=True, null=True)),
('description', models.TextField(blank=True, default='')),
('object_id', models.PositiveIntegerField(blank=True, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('assigned_to', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='activities', to=settings.AUTH_USER_MODEL)),
('content_type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='contenttypes.contenttype')),
],
options={
'ordering': ['-due_date', '-created_at'],
},
),
]