Skip to content

Commit 8d61375

Browse files
committed
Fix migrations
1 parent e584f0f commit 8d61375

File tree

9 files changed

+116
-61
lines changed

9 files changed

+116
-61
lines changed
Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,39 @@
11
# Generated by Django 4.2.11 on 2024-03-26 17:57
22

3+
import uuid
4+
35
from django.db import migrations, models
6+
47
import llmstack.apps.models
5-
import uuid
68

79

810
class Migration(migrations.Migration):
911

1012
dependencies = [
11-
('apps', '0010_alter_app_store_uuid'),
13+
("apps", "0010_alter_app_store_uuid"),
1214
]
1315

1416
operations = [
1517
migrations.CreateModel(
16-
name='AppSessionFiles',
18+
name="AppSessionFiles",
1719
fields=[
18-
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
19-
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, help_text='UUID of the asset')),
20-
('metadata', models.JSONField(blank=True, default=dict, help_text='Metadata for the asset', null=True)),
21-
('created_at', models.DateTimeField(auto_now_add=True)),
22-
('ref_id', models.UUIDField(blank=True, help_text='App session_id this file belongs to')),
23-
('file', models.FileField(blank=True, null=True, storage=llmstack.apps.models.select_storage, upload_to=llmstack.apps.models.appstore_upload_to)),
20+
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
21+
("uuid", models.UUIDField(default=uuid.uuid4, editable=False, help_text="UUID of the asset")),
22+
("metadata", models.JSONField(blank=True, default=dict, help_text="Metadata for the asset", null=True)),
23+
("created_at", models.DateTimeField(auto_now_add=True)),
24+
("ref_id", models.UUIDField(blank=True, help_text="App session_id this file belongs to")),
25+
(
26+
"file",
27+
models.FileField(
28+
blank=True,
29+
null=True,
30+
storage=llmstack.apps.models.AppSessionFiles.select_storage,
31+
upload_to=llmstack.apps.models.AppSessionFiles.appstore_upload_to,
32+
),
33+
),
2434
],
2535
options={
26-
'abstract': False,
36+
"abstract": False,
2737
},
2838
),
2939
]

llmstack/apps/migrations/0012_appdataassets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class Migration(migrations.Migration):
2727
models.FileField(
2828
blank=True,
2929
null=True,
30-
storage=llmstack.apps.models.select_storage,
31-
upload_to=llmstack.apps.models.appstore_upload_to,
30+
storage=llmstack.apps.models.AppDataAssets.select_storage,
31+
upload_to=llmstack.apps.models.AppDataAssets.appstore_upload_to,
3232
),
3333
),
3434
],
Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,51 @@
11
# Generated by Django 4.2.11 on 2024-04-30 19:16
22

3+
import uuid
4+
35
from django.db import migrations, models
6+
47
import llmstack.apps.models
5-
import uuid
68

79

810
class Migration(migrations.Migration):
911

1012
dependencies = [
11-
('apps', '0012_appdataassets'),
13+
("apps", "0012_appdataassets"),
1214
]
1315

1416
operations = [
1517
migrations.AlterField(
16-
model_name='app',
17-
name='uuid',
18-
field=models.UUIDField(default=uuid.uuid4, help_text='Identifier for the app', unique=True),
18+
model_name="app",
19+
name="uuid",
20+
field=models.UUIDField(default=uuid.uuid4, help_text="Identifier for the app", unique=True),
1921
),
2022
migrations.AlterField(
21-
model_name='appdataassets',
22-
name='file',
23-
field=models.FileField(blank=True, null=True, storage=llmstack.apps.models.select_storage, upload_to=llmstack.apps.models.appstore_upload_to),
23+
model_name="appdataassets",
24+
name="file",
25+
field=models.FileField(
26+
blank=True,
27+
null=True,
28+
storage=llmstack.apps.models.AppDataAssets.select_storage,
29+
upload_to=llmstack.apps.models.AppDataAssets.appstore_upload_to,
30+
),
2431
),
2532
migrations.AlterField(
26-
model_name='appdataassets',
27-
name='uuid',
28-
field=models.UUIDField(default=uuid.uuid4, editable=False, help_text='UUID of the asset', unique=True),
33+
model_name="appdataassets",
34+
name="uuid",
35+
field=models.UUIDField(default=uuid.uuid4, editable=False, help_text="UUID of the asset", unique=True),
2936
),
3037
migrations.AlterField(
31-
model_name='appsession',
32-
name='uuid',
33-
field=models.UUIDField(default=uuid.uuid4, help_text='UUID for the run', unique=True),
38+
model_name="appsession",
39+
name="uuid",
40+
field=models.UUIDField(default=uuid.uuid4, help_text="UUID for the run", unique=True),
3441
),
3542
migrations.AlterField(
36-
model_name='appsessionfiles',
37-
name='uuid',
38-
field=models.UUIDField(default=uuid.uuid4, editable=False, help_text='UUID of the asset', unique=True),
43+
model_name="appsessionfiles",
44+
name="uuid",
45+
field=models.UUIDField(default=uuid.uuid4, editable=False, help_text="UUID of the asset", unique=True),
3946
),
4047
migrations.AlterUniqueTogether(
41-
name='appdata',
42-
unique_together={('app_uuid', 'version')},
48+
name="appdata",
49+
unique_together={("app_uuid", "version")},
4350
),
4451
]
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
# Generated by Django 4.2.11 on 2024-04-30 20:11
22

33
from django.db import migrations, models
4+
45
import llmstack.apps.models
56

67

78
class Migration(migrations.Migration):
89

910
dependencies = [
10-
('apps', '0013_alter_app_uuid_alter_appdataassets_file_and_more'),
11+
("apps", "0013_alter_app_uuid_alter_appdataassets_file_and_more"),
1112
]
1213

1314
operations = [
1415
migrations.AlterField(
15-
model_name='appdataassets',
16-
name='file',
17-
field=models.FileField(blank=True, null=True, storage=llmstack.apps.models.select_storage, upload_to=llmstack.apps.models.appstore_upload_to),
16+
model_name="appdataassets",
17+
name="file",
18+
field=models.FileField(
19+
blank=True,
20+
null=True,
21+
storage=llmstack.apps.models.AppDataAssets.select_storage,
22+
upload_to=llmstack.apps.models.AppDataAssets.appstore_upload_to,
23+
),
1824
),
1925
]

llmstack/apps/models.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -534,17 +534,15 @@ def save(self, *args, **kwargs):
534534
return super().save(*args, **kwargs)
535535

536536

537-
def select_storage():
538-
from django.core.files.storage import storages
539-
540-
return storages["assets"]
541-
537+
class AppDataAssets(Assets):
538+
def select_storage():
539+
from django.core.files.storage import storages
542540

543-
def appstore_upload_to(instance, filename):
544-
return "/".join(["appdata", str(instance.ref_id), filename])
541+
return storages["assets"]
545542

543+
def appstore_upload_to(instance, filename):
544+
return "/".join(["appdata", str(instance.ref_id), filename])
546545

547-
class AppDataAssets(Assets):
548546
ref_id = models.UUIDField(help_text="Published UUID of the app this asset belongs to", null=False)
549547
file = models.FileField(
550548
storage=select_storage,
@@ -643,17 +641,15 @@ class AppSessionData(models.Model):
643641
)
644642

645643

646-
def select_storage():
647-
from django.core.files.storage import storages
648-
649-
return storages["assets"]
650-
644+
class AppSessionFiles(Assets):
645+
def select_storage():
646+
from django.core.files.storage import storages
651647

652-
def appstore_upload_to(instance, filename):
653-
return "/".join(["app_sessions", str(instance.ref_id), filename])
648+
return storages["assets"]
654649

650+
def appstore_upload_to(instance, filename):
651+
return "/".join(["app_sessions", str(instance.ref_id), filename])
655652

656-
class AppSessionFiles(Assets):
657653
ref_id = models.UUIDField(help_text="App session_id this file belongs to", blank=True, null=False)
658654
file = models.FileField(
659655
storage=select_storage,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Generated by Django 5.0.6 on 2024-06-04 07:04
2+
3+
import uuid
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('base', '0005_defaultprofile_mistral_api_key'),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name='defaultprofile',
16+
name='uuid',
17+
field=models.UUIDField(default=uuid.uuid4, help_text='User UUID', unique=True),
18+
),
19+
]

llmstack/datasources/migrations/0003_datasourceentryfiles.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class Migration(migrations.Migration):
2727
models.FileField(
2828
blank=True,
2929
null=True,
30-
storage=llmstack.datasources.models.select_storage,
31-
upload_to=llmstack.datasources.models.datasource_upload_to,
30+
storage=llmstack.datasources.models.DataSourceEntryFiles.select_storage,
31+
upload_to=llmstack.datasources.models.DataSourceEntryFiles.datasource_upload_to,
3232
),
3333
),
3434
],

llmstack/datasources/models.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,17 +221,15 @@ def register_data_delete(sender, instance: DataSourceEntry, **kwargs):
221221
)
222222

223223

224-
def select_storage():
225-
from django.core.files.storage import storages
226-
227-
return storages["assets"]
228-
224+
class DataSourceEntryFiles(Assets):
225+
def select_storage():
226+
from django.core.files.storage import storages
229227

230-
def datasource_upload_to(instance, filename):
231-
return "/".join(["datasource_entries", str(instance.ref_id), filename])
228+
return storages["assets"]
232229

230+
def datasource_upload_to(instance, filename):
231+
return "/".join(["datasource_entries", str(instance.ref_id), filename])
233232

234-
class DataSourceEntryFiles(Assets):
235233
ref_id = models.UUIDField(help_text="UUID of the datasource entry this file belongs to", blank=True, null=False)
236234
file = models.FileField(
237235
storage=select_storage,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Generated by Django 5.0.6 on 2024-06-04 14:33
2+
3+
import llmstack.common.utils.db_models
4+
from django.db import migrations
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('organizations', '0004_alter_organization_domains'),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name='organization',
16+
name='domains',
17+
field=llmstack.common.utils.db_models.ArrayField(help_text='List of allowed domains of the organization', null=True),
18+
),
19+
]

0 commit comments

Comments
 (0)