0001_squashed_0005_alter_apitoken_id.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # Generated by Django 4.1.3 on 2022-12-10 15:23
  2. import apps.api_tokens.models
  3. import bitfield.models
  4. from django.conf import settings
  5. from django.db import migrations, models
  6. import django.db.models.deletion
  7. class Migration(migrations.Migration):
  8. initial = True
  9. dependencies = [
  10. migrations.swappable_dependency(settings.AUTH_USER_MODEL),
  11. ]
  12. operations = [
  13. migrations.CreateModel(
  14. name="APIToken",
  15. fields=[
  16. (
  17. "id",
  18. models.BigAutoField(
  19. auto_created=True,
  20. primary_key=True,
  21. serialize=False,
  22. verbose_name="ID",
  23. ),
  24. ),
  25. (
  26. "token",
  27. models.CharField(
  28. default=apps.api_tokens.models.generate_token,
  29. editable=False,
  30. max_length=64,
  31. unique=True,
  32. ),
  33. ),
  34. ("label", models.CharField(blank=True, max_length=255)),
  35. (
  36. "scopes",
  37. bitfield.models.BitField(
  38. (
  39. "project:read",
  40. "project:write",
  41. "project:admin",
  42. "project:releases",
  43. "team:read",
  44. "team:write",
  45. "team:admin",
  46. "event:read",
  47. "event:write",
  48. "event:admin",
  49. "org:read",
  50. "org:write",
  51. "org:admin",
  52. "member:read",
  53. "member:write",
  54. "member:admin",
  55. ),
  56. default=None,
  57. ),
  58. ),
  59. ("created", models.DateTimeField(auto_now_add=True, db_index=True)),
  60. (
  61. "user",
  62. models.ForeignKey(
  63. on_delete=django.db.models.deletion.CASCADE,
  64. to=settings.AUTH_USER_MODEL,
  65. ),
  66. ),
  67. ],
  68. ),
  69. ]