Skip to content

Commit

Permalink
Merge pull request #120 from SmoFlaDru/dev-benno
Browse files Browse the repository at this point in the history
Fix database migrations problem by merging all migrations into one new migration
  • Loading branch information
Bensge authored Aug 28, 2024
2 parents c7311d4 + 365c859 commit 6a3ae4a
Show file tree
Hide file tree
Showing 25 changed files with 142 additions and 581 deletions.
3 changes: 2 additions & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ RECORDER_ENABLED=False
INSECURE_COOKIES=True
DJANGO_SUPERUSER_USERNAME=admin
DJANGO_SUPERUSER_PASSWORD=admin
STEAM_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
STEAM_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
SENTRY_ENABLED=False
6 changes: 6 additions & 0 deletions .idea/sqldialects.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 13 additions & 11 deletions Spybot2/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
STEAM_API_KEY = env('STEAM_API_KEY')

# Sentry SDK
SENTRY_DSN = env('SENTRY_DSN')
SENTRY_ENABLED = env.bool('SENTRY_ENABLED', False)
SENTRY_DSN = env('SENTRY_DSN', default="")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env.bool('DEBUG', False)
Expand Down Expand Up @@ -230,13 +231,14 @@
'javascript_in_head': False,
}

sentry_sdk.init(
dsn=SENTRY_DSN,
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for tracing.
traces_sample_rate=1.0,
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
)
if SENTRY_ENABLED:
sentry_sdk.init(
dsn=SENTRY_DSN,
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for tracing.
traces_sample_rate=1.0,
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
)
156 changes: 121 additions & 35 deletions spybot/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Generated by Django 4.1.3 on 2022-12-04 22:47
# Generated by Django 4.2.15 on 2024-08-27 16:22

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion

from spybot.models import MergedUserManager
import django.utils.timezone
import uuid


class Migration(migrations.Migration):
Expand All @@ -14,25 +15,31 @@ class Migration(migrations.Migration):
]

operations = [
migrations.SeparateDatabaseAndState(
state_operations=[
migrations.CreateModel(
name="MergedUser",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
)
],
options={"db_table": "auth_user"},
managers=[("objects", MergedUserManager())],
)
]
migrations.CreateModel(
name='MergedUser',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('password', models.CharField(max_length=128, verbose_name='password')),
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
('name', models.CharField(max_length=128)),
('obsolete', models.BooleanField(default=False)),
('is_superuser', models.BooleanField(default=False)),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='NewsEvent',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('text', models.CharField(max_length=1024)),
('website_link', models.CharField(max_length=256, null=True)),
('date', models.DateTimeField(auto_now_add=True)),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='TSChannel',
Expand All @@ -49,30 +56,30 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='TSUser',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('id', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(blank=True, max_length=128, null=True)),
('client_id', models.PositiveIntegerField(db_column='clientID')),
('online', models.BooleanField(db_column='isCurrentlyOnline', default=False)),
('merged_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='tsusers', to=settings.AUTH_USER_MODEL)),
],
options={
'db_table': 'TSUser',
'managed': True,
},
),
migrations.CreateModel(
name='TSUserActivity',
name='UserPasskey',
fields=[
('id', models.IntegerField(primary_key=True, serialize=False)),
('start_time', models.DateTimeField(blank=True, db_column='startTime', null=True)),
('end_time', models.DateTimeField(blank=True, db_column='endTime', null=True)),
('joined', models.BooleanField(default=False)),
('disconnect_id', models.IntegerField(blank=True, db_column='discID', null=True)),
('channel_id', models.ForeignKey(db_column='cID', on_delete=django.db.models.deletion.DO_NOTHING, to='spybot.tschannel')),
('tsuser_id', models.ForeignKey(blank=True, db_column='tsUserID', null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='spybot.tsuser')),
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
('enabled', models.BooleanField(default=True)),
('platform', models.CharField(default='', max_length=255)),
('added_on', models.DateTimeField(auto_now_add=True)),
('last_used', models.DateTimeField(default=None, null=True)),
('credential_id', models.CharField(max_length=255, unique=True)),
('token', models.CharField(max_length=1024)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
'db_table': 'TSUserActivity',
'managed': True,
},
),
migrations.CreateModel(
name='TSID',
Expand All @@ -85,4 +92,83 @@ class Migration(migrations.Migration):
'managed': True,
},
),
migrations.CreateModel(
name='SteamID',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('steam_id', models.BigIntegerField(default=0)),
('account_name', models.CharField(blank=True, max_length=128, null=True)),
('merged_user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='steamids', to=settings.AUTH_USER_MODEL)),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='QueuedClientMessage',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('text', models.CharField(max_length=1024)),
('type', models.CharField(max_length=128)),
('date', models.DateField(auto_now_add=True)),
('tsuser', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='spybot.tsuser')),
],
),
migrations.CreateModel(
name='LoginLink',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('code', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='loginlinks', to=settings.AUTH_USER_MODEL)),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='HourlyActivity',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('datetime', models.DateTimeField(default=django.utils.timezone.now)),
('activity_hours', models.FloatField()),
],
options={
'db_table': 'HourlyActivity',
'indexes': [models.Index(fields=['datetime'], name='HourlyActiv_datetim_96f0af_idx')],
},
),
migrations.CreateModel(
name='Award',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('date', models.DateTimeField(auto_now_add=True)),
('type', models.CharField(choices=[('USER_OF_WEEK', 'User of the week')], default='USER_OF_WEEK', max_length=64)),
('points', models.IntegerField()),
('tsuser', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='awards', to='spybot.tsuser')),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='TSUserActivity',
fields=[
('id', models.IntegerField(primary_key=True, serialize=False)),
('start_time', models.DateTimeField(blank=True, db_column='startTime', null=True)),
('end_time', models.DateTimeField(blank=True, db_column='endTime', null=True)),
('joined', models.BooleanField(default=False)),
('disconnect_id', models.IntegerField(blank=True, db_column='discID', null=True)),
('channel', models.ForeignKey(db_column='cID', on_delete=django.db.models.deletion.DO_NOTHING, to='spybot.tschannel')),
('tsuser', models.ForeignKey(blank=True, db_column='tsUserID', null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='spybot.tsuser')),
],
options={
'db_table': 'TSUserActivity',
'managed': True,
'indexes': [models.Index(fields=['start_time'], name='TSUserActiv_startTi_95ea75_idx')],
},
),
migrations.AddConstraint(
model_name='queuedclientmessage',
constraint=models.UniqueConstraint(fields=('tsuser', 'type'), name='constraint_unique_type_user'),
),
]
18 changes: 0 additions & 18 deletions spybot/migrations/0002_tsuser_online.py

This file was deleted.

This file was deleted.

25 changes: 0 additions & 25 deletions spybot/migrations/0004_hourlyactivity.py

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 6a3ae4a

Please sign in to comment.