chenzhaoyang
2025-12-17 d3e5a4b7658ece4f845bbc0c4f95acf3fbdf8a61
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import sys
import logging
 
from django.db import migrations
 
logger = logging.getLogger(__name__)
 
 
def forwards(apps, schema_editor):
    from tasks.functions import calculate_stats_all_orgs
    from django.conf import settings
 
    if settings.VERSION_EDITION == 'Community':
        run_command = 'label-studio calculate_stats_all_orgs'
    else:
        run_command = 'cd /label-studio-enterprise/label_studio_enterprise && ' \
                      'python3 manage.py calculate_stats_all_orgs'
 
    if '--skip-long-migrations' in sys.argv:
        logger.error(
            f"You used --skip-long-migrations, so you should run the migration manually as a separate process "
            f"to recalculate task counters, please use Django command `{run_command}`"
        )
        return
 
    logger.debug('=> Starting calculate_stats_all_orgs for task counters again')
    calculate_stats_all_orgs(from_scratch=False, redis=True)
 
 
def backwards(apps, schema_editor):
    pass
 
 
class Migration(migrations.Migration):
    atomic = False
 
    dependencies = [
        ('tasks', '0023_auto_20220620_1007'),
        ('core', '0001_initial'),
        ('projects', '0017_project_pinned_at'),
    ]
 
    operations = [
        migrations.RunPython(forwards, backwards),
    ]