Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested operations functions #36

Draft
wants to merge 25 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9fec6ac
Fixes bug with nested operations
kingbuzzman Jan 27, 2024
5de644a
Fixes issue with test app cache
kingbuzzman Jan 27, 2024
fded28f
all kinds of broken
kingbuzzman Jan 28, 2024
b22aef1
Merge branch 'master' into fix-nested-operation-func
kingbuzzman Jan 29, 2024
15bf86d
Merge branch 'fix-nested-operation-func' of github.com:kingbuzzman/dj…
kingbuzzman Jan 29, 2024
5d35401
WIP
kingbuzzman Jan 29, 2024
8489647
No need to do this anymore
kingbuzzman Jan 29, 2024
eaee979
no need to do this until the app isolation is not working
kingbuzzman Jan 29, 2024
86284a8
Merge branch 'master' into fix-nested-operation-func
kingbuzzman Jan 29, 2024
a07a79e
Merge branch 'fix-nested-operation-func' of github.com:kingbuzzman/dj…
kingbuzzman Jan 29, 2024
c971641
Removes import
kingbuzzman Jan 29, 2024
f81fd19
Merge branch 'master' into fix-nested-operation-func
kingbuzzman Feb 1, 2024
d84ccfd
Merge branch 'master' into fix-nested-operation-func
kingbuzzman Feb 1, 2024
ccb416d
Merge branch 'master' into fix-nested-operation-func
kingbuzzman Mar 3, 2024
86a01bf
Everything passes
kingbuzzman Mar 4, 2024
a3eae61
Clean up
kingbuzzman Mar 4, 2024
6f52734
No need to join
kingbuzzman Mar 4, 2024
ce4e573
Merge branch 'master' into fix-nested-operation-func
kingbuzzman Mar 4, 2024
b096ba4
Update test_migrations.py
kingbuzzman Mar 4, 2024
5ca2cce
Merge branch 'master' into fix-nested-operation-func
kingbuzzman Mar 5, 2024
261d3bc
Merge branch 'master' into fix-nested-operation-func
kingbuzzman Mar 20, 2024
24ff470
Merge branch 'master' into fix-nested-operation-func
kingbuzzman Mar 21, 2024
d4b3b5a
Merge branch 'master' into fix-nested-operation-func
kingbuzzman Mar 21, 2024
36325fa
Merge branch 'master' into fix-nested-operation-func
kingbuzzman Mar 26, 2024
3d72df3
Merge branch 'master' into fix-nested-operation-func
kingbuzzman Apr 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions tests/app/tests/migrations/xxx/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
("app3", "0001_inital"),
]

operations = [
migrations.CreateModel(
name="TranscodeJob",
fields=[
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("created_at", models.DateTimeField(auto_now_add=True, db_index=True)),
("updated_at", models.DateTimeField(auto_now=True)),
("job_id", models.CharField(max_length=50, unique=True)),
(
"status",
models.CharField(
choices=[
("S", "Submitted"),
("P", "Progressing"),
("C", "Complete"),
("X", "Canceled"),
("E", "Error"),
("U", "Unknown"),
],
default="S",
max_length=1,
),
),
("initial_response_data", models.TextField()),
("final_response_data", models.TextField()),
("video", models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to="app3.Person")),
],
options={
"abstract": False,
},
),
]
58 changes: 58 additions & 0 deletions tests/app/tests/migrations/xxx/0002_auto.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import django.contrib.contenttypes.models
import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("app", "0001_initial"),
]

def forwards_func(apps, schema_editor):
return

operations = [
migrations.AddField(
model_name="transcodejob",
name="content_type",
field=models.IntegerField(null=True, verbose_name=django.contrib.contenttypes.models.ContentType),
),
migrations.AddField(
model_name="transcodejob",
name="object_id",
field=models.BigIntegerField(null=True),
),
migrations.AlterField(
model_name="transcodejob",
name="job_id",
field=models.CharField(max_length=50, null=True, unique=True),
),
migrations.AlterField(
model_name="transcodejob",
name="status",
field=models.CharField(
choices=[
("R", "Ready"),
("S", "Submitted"),
("P", "Progressing"),
("C", "Complete"),
("X", "Canceled"),
("E", "Error"),
("U", "Unknown"),
],
default="S",
max_length=1,
),
),
migrations.AlterField(
model_name="transcodejob",
name="video",
field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, to="app3.Person"),
),
migrations.AlterIndexTogether(
name="transcodejob",
index_together=set([("content_type", "object_id")]),
),
migrations.RunPython(forwards_func, reverse_code=migrations.RunPython.noop),
]
Empty file.
41 changes: 41 additions & 0 deletions tests/test_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,47 @@ class Migration(migrations.Migration):
assert migration_app_dir.migration_read("0003_squashed.py", "") == expected


@pytest.mark.temporary_migration_module(module="app.tests.migrations.xxx", app_label="app")
@pytest.mark.temporary_migration_module2(module="app3.tests.migrations.moved", app_label="app3")
def test_nested(migration_app_dir, migration_app2_dir, call_squash_migrations, settings):
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType

class TranscodeJob(models.Model):

STATUS_CHOICES = (
("R", "Ready"),
("S", "Submitted"),
("P", "Progressing"),
("C", "Complete"),
("X", "Canceled"),
("E", "Error"),
("U", "Unknown"),
)

content_type = models.IntegerField(ContentType, null=True)
object_id = models.BigIntegerField(null=True)
content_object = GenericForeignKey("content_type", "object_id")

video = models.OneToOneField("app3.Person", on_delete=models.CASCADE, null=True)
job_id = models.CharField(max_length=50, unique=True, null=True)
status = models.CharField(max_length=1, choices=STATUS_CHOICES, default="S")
initial_response_data = models.TextField()
final_response_data = models.TextField()

class Meta:
app_label = "app"

class Person(models.Model):
name = models.CharField(max_length=10)
dob = models.DateField()

class Meta:
app_label = "app3"

call_squash_migrations()


@pytest.mark.temporary_migration_module(module="app.tests.migrations.pg_indexes", app_label="app")
def test_squashing_migration_pg_indexes(migration_app_dir, call_squash_migrations):

Expand Down
Loading