bottleneckcrm/backend/common/migrations/0001_initial.py

1610 lines
62 KiB
Python

# Generated by Django 5.2.8 on 2025-11-27 12:17
import uuid
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
import common.models
class Migration(migrations.Migration):
initial = True
dependencies = [
("auth", "0012_alter_user_first_name_max_length"),
("contenttypes", "0002_remove_content_type_name"),
]
operations = [
migrations.CreateModel(
name="User",
fields=[
("password", models.CharField(max_length=128, verbose_name="password")),
(
"last_login",
models.DateTimeField(
blank=True, null=True, verbose_name="last login"
),
),
(
"is_superuser",
models.BooleanField(
default=False,
help_text="Designates that this user has all permissions without explicitly assigning them.",
verbose_name="superuser status",
),
),
(
"id",
models.UUIDField(
db_index=True,
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
unique=True,
),
),
(
"email",
models.EmailField(
blank=True,
max_length=254,
unique=True,
verbose_name="email address",
),
),
(
"profile_pic",
models.CharField(blank=True, max_length=1000, null=True),
),
(
"activation_key",
models.CharField(blank=True, max_length=150, null=True),
),
("key_expires", models.DateTimeField(blank=True, null=True)),
("is_active", models.BooleanField(default=True)),
(
"is_staff",
models.BooleanField(default=False, verbose_name="staff status"),
),
(
"groups",
models.ManyToManyField(
blank=True,
help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.",
related_name="user_set",
related_query_name="user",
to="auth.group",
verbose_name="groups",
),
),
(
"user_permissions",
models.ManyToManyField(
blank=True,
help_text="Specific permissions for this user.",
related_name="user_set",
related_query_name="user",
to="auth.permission",
verbose_name="user permissions",
),
),
],
options={
"verbose_name": "User",
"verbose_name_plural": "Users",
"db_table": "users",
"ordering": ("-is_active",),
},
),
migrations.CreateModel(
name="Comment",
fields=[
(
"created_at",
models.DateTimeField(auto_now_add=True, verbose_name="Created At"),
),
(
"updated_at",
models.DateTimeField(
auto_now=True, verbose_name="Last Modified At"
),
),
(
"id",
models.UUIDField(
db_index=True,
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
unique=True,
),
),
("object_id", models.UUIDField()),
("comment", models.CharField(max_length=255)),
("commented_on", models.DateTimeField(auto_now_add=True)),
(
"content_type",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="comments",
to="contenttypes.contenttype",
),
),
(
"created_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_created_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Created By",
),
),
(
"updated_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_updated_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Last Modified By",
),
),
],
options={
"verbose_name": "Comment",
"verbose_name_plural": "Comments",
"db_table": "comment",
"ordering": ("-created_at",),
},
),
migrations.CreateModel(
name="CommentFiles",
fields=[
(
"created_at",
models.DateTimeField(auto_now_add=True, verbose_name="Created At"),
),
(
"updated_at",
models.DateTimeField(
auto_now=True, verbose_name="Last Modified At"
),
),
(
"id",
models.UUIDField(
db_index=True,
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
unique=True,
),
),
(
"comment_file",
models.FileField(
blank=True,
null=True,
upload_to="CommentFiles",
verbose_name="File",
),
),
(
"comment",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="common.comment"
),
),
(
"created_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_created_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Created By",
),
),
(
"updated_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_updated_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Last Modified By",
),
),
],
options={
"verbose_name": "CommentFile",
"verbose_name_plural": "CommentFiles",
"db_table": "commentFiles",
"ordering": ("-created_at",),
},
),
migrations.CreateModel(
name="Org",
fields=[
(
"created_at",
models.DateTimeField(auto_now_add=True, verbose_name="Created At"),
),
(
"updated_at",
models.DateTimeField(
auto_now=True, verbose_name="Last Modified At"
),
),
(
"id",
models.UUIDField(
db_index=True,
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
unique=True,
),
),
("name", models.CharField(blank=True, max_length=100, null=True)),
(
"api_key",
models.TextField(
default=common.models.generate_unique_key,
editable=False,
unique=True,
),
),
("is_active", models.BooleanField(default=True)),
(
"created_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_created_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Created By",
),
),
(
"updated_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_updated_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Last Modified By",
),
),
],
options={
"verbose_name": "Organization",
"verbose_name_plural": "Organizations",
"db_table": "organization",
"ordering": ("-created_at",),
},
),
migrations.AddField(
model_name="comment",
name="org",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="comments",
to="common.org",
),
),
migrations.CreateModel(
name="Address",
fields=[
(
"created_at",
models.DateTimeField(auto_now_add=True, verbose_name="Created At"),
),
(
"updated_at",
models.DateTimeField(
auto_now=True, verbose_name="Last Modified At"
),
),
(
"id",
models.UUIDField(
db_index=True,
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
unique=True,
),
),
(
"address_line",
models.CharField(
blank=True, default="", max_length=255, verbose_name="Address"
),
),
(
"street",
models.CharField(
blank=True, default="", max_length=55, verbose_name="Street"
),
),
(
"city",
models.CharField(
blank=True, default="", max_length=255, verbose_name="City"
),
),
(
"state",
models.CharField(
blank=True, default="", max_length=255, verbose_name="State"
),
),
(
"postcode",
models.CharField(
blank=True,
default="",
max_length=64,
verbose_name="Post/Zip-code",
),
),
(
"country",
models.CharField(
blank=True,
choices=[
("GB", "United Kingdom"),
("AF", "Afghanistan"),
("AX", "Aland Islands"),
("AL", "Albania"),
("DZ", "Algeria"),
("AS", "American Samoa"),
("AD", "Andorra"),
("AO", "Angola"),
("AI", "Anguilla"),
("AQ", "Antarctica"),
("AG", "Antigua and Barbuda"),
("AR", "Argentina"),
("AM", "Armenia"),
("AW", "Aruba"),
("AU", "Australia"),
("AT", "Austria"),
("AZ", "Azerbaijan"),
("BS", "Bahamas"),
("BH", "Bahrain"),
("BD", "Bangladesh"),
("BB", "Barbados"),
("BY", "Belarus"),
("BE", "Belgium"),
("BZ", "Belize"),
("BJ", "Benin"),
("BM", "Bermuda"),
("BT", "Bhutan"),
("BO", "Bolivia"),
("BA", "Bosnia and Herzegovina"),
("BW", "Botswana"),
("BV", "Bouvet Island"),
("BR", "Brazil"),
("IO", "British Indian Ocean Territory"),
("BN", "Brunei Darussalam"),
("BG", "Bulgaria"),
("BF", "Burkina Faso"),
("BI", "Burundi"),
("KH", "Cambodia"),
("CM", "Cameroon"),
("CA", "Canada"),
("CV", "Cape Verde"),
("KY", "Cayman Islands"),
("CF", "Central African Republic"),
("TD", "Chad"),
("CL", "Chile"),
("CN", "China"),
("CX", "Christmas Island"),
("CC", "Cocos (Keeling) Islands"),
("CO", "Colombia"),
("KM", "Comoros"),
("CG", "Congo"),
("CD", "Congo, The Democratic Republic of the"),
("CK", "Cook Islands"),
("CR", "Costa Rica"),
("CI", "Cote d'Ivoire"),
("HR", "Croatia"),
("CU", "Cuba"),
("CY", "Cyprus"),
("CZ", "Czech Republic"),
("DK", "Denmark"),
("DJ", "Djibouti"),
("DM", "Dominica"),
("DO", "Dominican Republic"),
("EC", "Ecuador"),
("EG", "Egypt"),
("SV", "El Salvador"),
("GQ", "Equatorial Guinea"),
("ER", "Eritrea"),
("EE", "Estonia"),
("ET", "Ethiopia"),
("FK", "Falkland Islands (Malvinas)"),
("FO", "Faroe Islands"),
("FJ", "Fiji"),
("FI", "Finland"),
("FR", "France"),
("GF", "French Guiana"),
("PF", "French Polynesia"),
("TF", "French Southern Territories"),
("GA", "Gabon"),
("GM", "Gambia"),
("GE", "Georgia"),
("DE", "Germany"),
("GH", "Ghana"),
("GI", "Gibraltar"),
("GR", "Greece"),
("GL", "Greenland"),
("GD", "Grenada"),
("GP", "Guadeloupe"),
("GU", "Guam"),
("GT", "Guatemala"),
("GG", "Guernsey"),
("GN", "Guinea"),
("GW", "Guinea-Bissau"),
("GY", "Guyana"),
("HT", "Haiti"),
("HM", "Heard Island and McDonald Islands"),
("VA", "Holy See (Vatican City State)"),
("HN", "Honduras"),
("HK", "Hong Kong"),
("HU", "Hungary"),
("IS", "Iceland"),
("IN", "India"),
("ID", "Indonesia"),
("IR", "Iran, Islamic Republic of"),
("IQ", "Iraq"),
("IE", "Ireland"),
("IM", "Isle of Man"),
("IL", "Israel"),
("IT", "Italy"),
("JM", "Jamaica"),
("JP", "Japan"),
("JE", "Jersey"),
("JO", "Jordan"),
("KZ", "Kazakhstan"),
("KE", "Kenya"),
("KI", "Kiribati"),
("KP", "Korea, Democratic People's Republic of"),
("KR", "Korea, Republic of"),
("KW", "Kuwait"),
("KG", "Kyrgyzstan"),
("LA", "Lao People's Democratic Republic"),
("LV", "Latvia"),
("LB", "Lebanon"),
("LS", "Lesotho"),
("LR", "Liberia"),
("LY", "Libyan Arab Jamahiriya"),
("LI", "Liechtenstein"),
("LT", "Lithuania"),
("LU", "Luxembourg"),
("MO", "Macao"),
("MK", "Macedonia, The Former Yugoslav Republic of"),
("MG", "Madagascar"),
("MW", "Malawi"),
("MY", "Malaysia"),
("MV", "Maldives"),
("ML", "Mali"),
("MT", "Malta"),
("MH", "Marshall Islands"),
("MQ", "Martinique"),
("MR", "Mauritania"),
("MU", "Mauritius"),
("YT", "Mayotte"),
("MX", "Mexico"),
("FM", "Micronesia, Federated States of"),
("MD", "Moldova"),
("MC", "Monaco"),
("MN", "Mongolia"),
("ME", "Montenegro"),
("MS", "Montserrat"),
("MA", "Morocco"),
("MZ", "Mozambique"),
("MM", "Myanmar"),
("NA", "Namibia"),
("NR", "Nauru"),
("NP", "Nepal"),
("NL", "Netherlands"),
("AN", "Netherlands Antilles"),
("NC", "New Caledonia"),
("NZ", "New Zealand"),
("NI", "Nicaragua"),
("NE", "Niger"),
("NG", "Nigeria"),
("NU", "Niue"),
("NF", "Norfolk Island"),
("MP", "Northern Mariana Islands"),
("NO", "Norway"),
("OM", "Oman"),
("PK", "Pakistan"),
("PW", "Palau"),
("PS", "Palestinian Territory, Occupied"),
("PA", "Panama"),
("PG", "Papua New Guinea"),
("PY", "Paraguay"),
("PE", "Peru"),
("PH", "Philippines"),
("PN", "Pitcairn"),
("PL", "Poland"),
("PT", "Portugal"),
("PR", "Puerto Rico"),
("QA", "Qatar"),
("RE", "Reunion"),
("RO", "Romania"),
("RU", "Russian Federation"),
("RW", "Rwanda"),
("BL", "Saint Barthelemy"),
("SH", "Saint Helena"),
("KN", "Saint Kitts and Nevis"),
("LC", "Saint Lucia"),
("MF", "Saint Martin"),
("PM", "Saint Pierre and Miquelon"),
("VC", "Saint Vincent and the Grenadines"),
("WS", "Samoa"),
("SM", "San Marino"),
("ST", "Sao Tome and Principe"),
("SA", "Saudi Arabia"),
("SN", "Senegal"),
("RS", "Serbia"),
("SC", "Seychelles"),
("SL", "Sierra Leone"),
("SG", "Singapore"),
("SK", "Slovakia"),
("SI", "Slovenia"),
("SB", "Solomon Islands"),
("SO", "Somalia"),
("ZA", "South Africa"),
("GS", "South Georgia and the South Sandwich Islands"),
("ES", "Spain"),
("LK", "Sri Lanka"),
("SD", "Sudan"),
("SR", "Suriname"),
("SJ", "Svalbard and Jan Mayen"),
("SZ", "Swaziland"),
("SE", "Sweden"),
("CH", "Switzerland"),
("SY", "Syrian Arab Republic"),
("TW", "Taiwan, Province of China"),
("TJ", "Tajikistan"),
("TZ", "Tanzania, United Republic of"),
("TH", "Thailand"),
("TL", "Timor-Leste"),
("TG", "Togo"),
("TK", "Tokelau"),
("TO", "Tonga"),
("TT", "Trinidad and Tobago"),
("TN", "Tunisia"),
("TR", "Turkey"),
("TM", "Turkmenistan"),
("TC", "Turks and Caicos Islands"),
("TV", "Tuvalu"),
("UG", "Uganda"),
("UA", "Ukraine"),
("AE", "United Arab Emirates"),
("US", "United States"),
("UM", "United States Minor Outlying Islands"),
("UY", "Uruguay"),
("UZ", "Uzbekistan"),
("VU", "Vanuatu"),
("VE", "Venezuela"),
("VN", "Viet Nam"),
("VG", "Virgin Islands, British"),
("VI", "Virgin Islands, U.S."),
("WF", "Wallis and Futuna"),
("EH", "Western Sahara"),
("YE", "Yemen"),
("ZM", "Zambia"),
("ZW", "Zimbabwe"),
],
default="",
max_length=3,
),
),
(
"created_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_created_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Created By",
),
),
(
"updated_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_updated_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Last Modified By",
),
),
(
"org",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="addresses",
to="common.org",
),
),
],
options={
"verbose_name": "Address",
"verbose_name_plural": "Addresses",
"db_table": "address",
"ordering": ("-created_at",),
},
),
migrations.CreateModel(
name="Profile",
fields=[
(
"created_at",
models.DateTimeField(auto_now_add=True, verbose_name="Created At"),
),
(
"updated_at",
models.DateTimeField(
auto_now=True, verbose_name="Last Modified At"
),
),
(
"id",
models.UUIDField(
db_index=True,
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
unique=True,
),
),
(
"phone",
models.CharField(blank=True, max_length=20, null=True),
),
(
"alternate_phone",
models.CharField(blank=True, max_length=20, null=True),
),
(
"role",
models.CharField(
choices=[("ADMIN", "ADMIN"), ("USER", "USER")],
default="USER",
max_length=50,
),
),
("has_sales_access", models.BooleanField(default=False)),
("has_marketing_access", models.BooleanField(default=False)),
("is_active", models.BooleanField(default=True)),
("is_organization_admin", models.BooleanField(default=False)),
("date_of_joining", models.DateField(blank=True, null=True)),
(
"address",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="address_users",
to="common.address",
),
),
(
"created_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_created_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Created By",
),
),
(
"org",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="profiles",
to="common.org",
),
),
(
"updated_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_updated_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Last Modified By",
),
),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="profiles",
to=settings.AUTH_USER_MODEL,
),
),
],
options={
"verbose_name": "Profile",
"verbose_name_plural": "Profiles",
"db_table": "profile",
"ordering": ("-created_at",),
"unique_together": {("phone", "org"), ("user", "org")},
},
),
migrations.AddField(
model_name="comment",
name="commented_by",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
to="common.profile",
),
),
migrations.CreateModel(
name="Activity",
fields=[
(
"created_at",
models.DateTimeField(auto_now_add=True, verbose_name="Created At"),
),
(
"updated_at",
models.DateTimeField(
auto_now=True, verbose_name="Last Modified At"
),
),
(
"id",
models.UUIDField(
db_index=True,
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
unique=True,
),
),
(
"action",
models.CharField(
choices=[
("CREATE", "Created"),
("UPDATE", "Updated"),
("DELETE", "Deleted"),
("VIEW", "Viewed"),
("COMMENT", "Commented"),
("ASSIGN", "Assigned"),
],
max_length=20,
),
),
(
"entity_type",
models.CharField(
choices=[
("Account", "Account"),
("Lead", "Lead"),
("Contact", "Contact"),
("Opportunity", "Opportunity"),
("Case", "Case"),
("Task", "Task"),
("Invoice", "Invoice"),
("Event", "Event"),
("Document", "Document"),
("Team", "Team"),
],
max_length=50,
),
),
("entity_id", models.UUIDField()),
(
"entity_name",
models.CharField(blank=True, default="", max_length=255),
),
("description", models.TextField(blank=True, default="")),
(
"created_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_created_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Created By",
),
),
(
"updated_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_updated_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Last Modified By",
),
),
(
"org",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="activities",
to="common.org",
),
),
(
"user",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="activities",
to="common.profile",
),
),
],
options={
"verbose_name": "Activity",
"verbose_name_plural": "Activities",
"db_table": "activity",
"ordering": ("-created_at",),
},
),
migrations.CreateModel(
name="SecurityAuditLog",
fields=[
(
"created_at",
models.DateTimeField(auto_now_add=True, verbose_name="Created At"),
),
(
"updated_at",
models.DateTimeField(
auto_now=True, verbose_name="Last Modified At"
),
),
(
"id",
models.UUIDField(
db_index=True,
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
unique=True,
),
),
(
"event_type",
models.CharField(
choices=[
("LOGIN_SUCCESS", "Login Success"),
("LOGIN_FAILURE", "Login Failure"),
("LOGOUT", "Logout"),
("ORG_SWITCH", "Organization Switch"),
("TOKEN_REFRESH", "Token Refresh"),
("TOKEN_REVOKED", "Token Revoked"),
("PERMISSION_DENIED", "Permission Denied"),
("CROSS_ORG_ATTEMPT", "Cross-Org Access Attempt"),
("API_KEY_USED", "API Key Used"),
("API_KEY_INVALID", "Invalid API Key"),
("MEMBERSHIP_REVOKED", "Membership Revoked"),
("SUSPICIOUS_ACTIVITY", "Suspicious Activity"),
],
db_index=True,
max_length=50,
),
),
("description", models.TextField(blank=True, default="")),
("metadata", models.JSONField(blank=True, default=dict)),
("ip_address", models.GenericIPAddressField(blank=True, null=True)),
("user_agent", models.TextField(blank=True, default="")),
(
"request_path",
models.CharField(blank=True, default="", max_length=500),
),
(
"request_method",
models.CharField(blank=True, default="", max_length=10),
),
("success", models.BooleanField(default=True)),
(
"created_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_created_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Created By",
),
),
(
"org",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="security_audit_logs",
to="common.org",
),
),
(
"updated_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_updated_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Last Modified By",
),
),
(
"user",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="security_audit_logs",
to=settings.AUTH_USER_MODEL,
),
),
],
options={
"verbose_name": "Security Audit Log",
"verbose_name_plural": "Security Audit Logs",
"db_table": "security_audit_log",
"ordering": ("-created_at",),
},
),
migrations.CreateModel(
name="SessionToken",
fields=[
(
"created_at",
models.DateTimeField(auto_now_add=True, verbose_name="Created At"),
),
(
"updated_at",
models.DateTimeField(
auto_now=True, verbose_name="Last Modified At"
),
),
(
"id",
models.UUIDField(
db_index=True,
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
unique=True,
),
),
(
"token_jti",
models.CharField(db_index=True, max_length=255, unique=True),
),
(
"refresh_token_jti",
models.CharField(
blank=True,
db_index=True,
max_length=255,
null=True,
unique=True,
),
),
("ip_address", models.GenericIPAddressField(blank=True, null=True)),
("user_agent", models.TextField(blank=True, null=True)),
("expires_at", models.DateTimeField()),
("is_active", models.BooleanField(default=True)),
("revoked_at", models.DateTimeField(blank=True, null=True)),
("last_used_at", models.DateTimeField(auto_now=True)),
(
"created_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_created_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Created By",
),
),
(
"updated_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_updated_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Last Modified By",
),
),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="session_tokens",
to=settings.AUTH_USER_MODEL,
),
),
],
options={
"verbose_name": "Session Token",
"verbose_name_plural": "Session Tokens",
"db_table": "session_token",
"ordering": ("-created_at",),
},
),
migrations.CreateModel(
name="Tags",
fields=[
(
"created_at",
models.DateTimeField(auto_now_add=True, verbose_name="Created At"),
),
(
"updated_at",
models.DateTimeField(
auto_now=True, verbose_name="Last Modified At"
),
),
(
"id",
models.UUIDField(
db_index=True,
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
unique=True,
),
),
("name", models.CharField(max_length=20)),
("slug", models.CharField(blank=True, max_length=20)),
(
"created_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_created_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Created By",
),
),
(
"org",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="tags",
to="common.org",
),
),
(
"updated_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_updated_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Last Modified By",
),
),
],
options={
"verbose_name": "Tag",
"verbose_name_plural": "Tags",
"db_table": "tags",
"ordering": ("-created_at",),
},
),
migrations.CreateModel(
name="APISettings",
fields=[
(
"created_at",
models.DateTimeField(auto_now_add=True, verbose_name="Created At"),
),
(
"updated_at",
models.DateTimeField(
auto_now=True, verbose_name="Last Modified At"
),
),
(
"id",
models.UUIDField(
db_index=True,
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
unique=True,
),
),
("title", models.TextField()),
("apikey", models.CharField(blank=True, max_length=16)),
("website", models.URLField(max_length=255, null=True)),
(
"created_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_created_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Created By",
),
),
(
"updated_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_updated_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Last Modified By",
),
),
(
"org",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="api_settings",
to="common.org",
),
),
(
"lead_assigned_to",
models.ManyToManyField(
related_name="lead_assignee_users", to="common.profile"
),
),
("tags", models.ManyToManyField(blank=True, to="common.tags")),
],
options={
"verbose_name": "APISetting",
"verbose_name_plural": "APISettings",
"db_table": "apiSettings",
"ordering": ("-created_at",),
},
),
migrations.CreateModel(
name="Teams",
fields=[
(
"created_at",
models.DateTimeField(auto_now_add=True, verbose_name="Created At"),
),
(
"updated_at",
models.DateTimeField(
auto_now=True, verbose_name="Last Modified At"
),
),
(
"id",
models.UUIDField(
db_index=True,
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
unique=True,
),
),
("name", models.CharField(max_length=100)),
("description", models.TextField()),
(
"created_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_created_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Created By",
),
),
(
"org",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="teams",
to="common.org",
),
),
(
"updated_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_updated_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Last Modified By",
),
),
(
"users",
models.ManyToManyField(
related_name="user_teams", to="common.profile"
),
),
],
options={
"verbose_name": "Team",
"verbose_name_plural": "Teams",
"db_table": "teams",
"ordering": ("-created_at",),
},
),
migrations.CreateModel(
name="Document",
fields=[
(
"created_at",
models.DateTimeField(auto_now_add=True, verbose_name="Created At"),
),
(
"updated_at",
models.DateTimeField(
auto_now=True, verbose_name="Last Modified At"
),
),
(
"id",
models.UUIDField(
db_index=True,
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
unique=True,
),
),
("title", models.TextField(blank=True, null=True)),
(
"document_file",
models.FileField(
max_length=5000, upload_to=common.models.document_path
),
),
(
"status",
models.CharField(
choices=[("active", "active"), ("inactive", "inactive")],
default="active",
max_length=64,
),
),
(
"created_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_created_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Created By",
),
),
(
"updated_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_updated_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Last Modified By",
),
),
(
"org",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="documents",
to="common.org",
),
),
(
"shared_to",
models.ManyToManyField(
related_name="document_shared_to", to="common.profile"
),
),
(
"teams",
models.ManyToManyField(
related_name="document_teams", to="common.teams"
),
),
],
options={
"verbose_name": "Document",
"verbose_name_plural": "Documents",
"db_table": "document",
"ordering": ("-created_at",),
},
),
migrations.CreateModel(
name="ContactFormSubmission",
fields=[
(
"created_at",
models.DateTimeField(auto_now_add=True, verbose_name="Created At"),
),
(
"updated_at",
models.DateTimeField(
auto_now=True, verbose_name="Last Modified At"
),
),
(
"id",
models.UUIDField(
db_index=True,
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
unique=True,
),
),
("name", models.CharField(max_length=255)),
("email", models.EmailField(max_length=254)),
("message", models.TextField()),
(
"reason",
models.CharField(
choices=[
("general", "General Inquiry"),
("sales", "Sales Question"),
("support", "Technical Support"),
("partnership", "Partnership Opportunity"),
("other", "Other"),
],
default="general",
max_length=100,
),
),
("ip_address", models.GenericIPAddressField(blank=True, null=True)),
("user_agent", models.TextField(blank=True, null=True)),
("referrer", models.URLField(blank=True, max_length=500, null=True)),
(
"status",
models.CharField(
choices=[
("new", "New"),
("read", "Read"),
("replied", "Replied"),
("closed", "Closed"),
],
default="new",
max_length=20,
),
),
("replied_at", models.DateTimeField(blank=True, null=True)),
(
"created_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_created_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Created By",
),
),
(
"replied_by",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="contact_replies",
to=settings.AUTH_USER_MODEL,
),
),
(
"updated_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_updated_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Last Modified By",
),
),
],
options={
"verbose_name": "Contact Form Submission",
"verbose_name_plural": "Contact Form Submissions",
"db_table": "contact_form_submission",
"ordering": ["-created_at"],
"indexes": [
models.Index(fields=["email"], name="contact_for_email_534ce8_idx"),
models.Index(
fields=["status"], name="contact_for_status_b48047_idx"
),
models.Index(
fields=["created_at"], name="contact_for_created_f54fb1_idx"
),
],
},
),
migrations.CreateModel(
name="Attachments",
fields=[
(
"created_at",
models.DateTimeField(auto_now_add=True, verbose_name="Created At"),
),
(
"updated_at",
models.DateTimeField(
auto_now=True, verbose_name="Last Modified At"
),
),
(
"id",
models.UUIDField(
db_index=True,
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
unique=True,
),
),
("object_id", models.UUIDField()),
("file_name", models.CharField(max_length=60)),
(
"attachment",
models.FileField(max_length=1001, upload_to="attachments/%Y/%m/"),
),
(
"content_type",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="attachments",
to="contenttypes.contenttype",
),
),
(
"created_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_created_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Created By",
),
),
(
"updated_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_updated_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Last Modified By",
),
),
(
"org",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="attachments",
to="common.org",
),
),
],
options={
"verbose_name": "Attachment",
"verbose_name_plural": "Attachments",
"db_table": "attachments",
"ordering": ("-created_at",),
"indexes": [
models.Index(
fields=["content_type", "object_id"],
name="attachments_content_7c0e26_idx",
),
models.Index(
fields=["org", "-created_at"],
name="attachments_org_id_432f7a_idx",
),
],
},
),
migrations.AddIndex(
model_name="comment",
index=models.Index(
fields=["content_type", "object_id"], name="comment_content_3076b0_idx"
),
),
migrations.AddIndex(
model_name="comment",
index=models.Index(
fields=["org", "-created_at"], name="comment_org_id_ae4e49_idx"
),
),
migrations.AddIndex(
model_name="activity",
index=models.Index(
fields=["org", "-created_at"], name="activity_org_id_832f39_idx"
),
),
migrations.AddIndex(
model_name="activity",
index=models.Index(
fields=["entity_type", "entity_id"], name="activity_entity__e33c9a_idx"
),
),
migrations.AddIndex(
model_name="securityauditlog",
index=models.Index(
fields=["event_type", "-created_at"],
name="security_au_event_t_5c4296_idx",
),
),
migrations.AddIndex(
model_name="securityauditlog",
index=models.Index(
fields=["user", "-created_at"], name="security_au_user_id_ab6fd5_idx"
),
),
migrations.AddIndex(
model_name="securityauditlog",
index=models.Index(
fields=["org", "-created_at"], name="security_au_org_id_d5d1da_idx"
),
),
migrations.AddIndex(
model_name="securityauditlog",
index=models.Index(
fields=["ip_address"], name="security_au_ip_addr_a572f5_idx"
),
),
migrations.AddIndex(
model_name="securityauditlog",
index=models.Index(
fields=["success", "-created_at"], name="security_au_success_c444de_idx"
),
),
migrations.AddIndex(
model_name="sessiontoken",
index=models.Index(
fields=["user", "is_active"], name="session_tok_user_id_ce3d01_idx"
),
),
migrations.AddIndex(
model_name="sessiontoken",
index=models.Index(
fields=["token_jti"], name="session_tok_token_j_a0ab6c_idx"
),
),
migrations.AddIndex(
model_name="sessiontoken",
index=models.Index(
fields=["expires_at"], name="session_tok_expires_08e0bc_idx"
),
),
migrations.AlterUniqueTogether(
name="tags",
unique_together={("slug", "org")},
),
]