Skip to content

Commit 2320ee9

Browse files
committed
wip files
1 parent 6928324 commit 2320ee9

File tree

3 files changed

+181
-1
lines changed

3 files changed

+181
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Generated by Django 4.2.3 on 2024-03-07 02:35
2+
3+
from django.db import migrations, models
4+
import pgtrigger.compiler
5+
import pgtrigger.migrations
6+
7+
8+
class Migration(migrations.Migration):
9+
dependencies = [
10+
("baseapp_files", "0001_initial"),
11+
]
12+
13+
operations = [
14+
pgtrigger.migrations.RemoveTrigger(
15+
model_name="file",
16+
name="snapshot_insert",
17+
),
18+
pgtrigger.migrations.RemoveTrigger(
19+
model_name="file",
20+
name="snapshot_update",
21+
),
22+
migrations.AddField(
23+
model_name="fileevent",
24+
name="pgh_operation",
25+
field=models.IntegerField(
26+
choices=[
27+
(1, "Insert"),
28+
(2, "Update"),
29+
(3, "Delete"),
30+
(4, "Insertorupdate"),
31+
],
32+
null=True,
33+
),
34+
),
35+
pgtrigger.migrations.AddTrigger(
36+
model_name="file",
37+
trigger=pgtrigger.compiler.Trigger(
38+
name="snapshot_insert",
39+
sql=pgtrigger.compiler.UpsertTriggerSql(
40+
func='INSERT INTO "baseapp_files_fileevent" ("content_type", "created", "created_by_id", "description", "file", "file_name", "file_size", "id", "modified", "name", "parent_content_type_id", "parent_object_id", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "pgh_operation", "updated") VALUES (NEW."content_type", NEW."created", NEW."created_by_id", NEW."description", NEW."file", NEW."file_name", NEW."file_size", NEW."id", NEW."modified", NEW."name", NEW."parent_content_type_id", NEW."parent_object_id", _pgh_attach_context(), NOW(), \'snapshot\', NEW."id", 1, NEW."updated"); RETURN NULL;',
41+
hash="df20bf9549839bb058bec50b2ec00b48b1dcb66c",
42+
operation="INSERT",
43+
pgid="pgtrigger_snapshot_insert_03cf9",
44+
table="baseapp_files_file",
45+
when="AFTER",
46+
),
47+
),
48+
),
49+
pgtrigger.migrations.AddTrigger(
50+
model_name="file",
51+
trigger=pgtrigger.compiler.Trigger(
52+
name="snapshot_update",
53+
sql=pgtrigger.compiler.UpsertTriggerSql(
54+
condition="WHEN (OLD.* IS DISTINCT FROM NEW.*)",
55+
func='INSERT INTO "baseapp_files_fileevent" ("content_type", "created", "created_by_id", "description", "file", "file_name", "file_size", "id", "modified", "name", "parent_content_type_id", "parent_object_id", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "pgh_operation", "updated") VALUES (NEW."content_type", NEW."created", NEW."created_by_id", NEW."description", NEW."file", NEW."file_name", NEW."file_size", NEW."id", NEW."modified", NEW."name", NEW."parent_content_type_id", NEW."parent_object_id", _pgh_attach_context(), NOW(), \'snapshot\', NEW."id", 2, NEW."updated"); RETURN NULL;',
56+
hash="a4b2ac3b6afa90f1fb04a72fd1d2a81064d6824d",
57+
operation="UPDATE",
58+
pgid="pgtrigger_snapshot_update_11b9c",
59+
table="baseapp_files_file",
60+
when="AFTER",
61+
),
62+
),
63+
),
64+
pgtrigger.migrations.AddTrigger(
65+
model_name="file",
66+
trigger=pgtrigger.compiler.Trigger(
67+
name="snapshot_delete",
68+
sql=pgtrigger.compiler.UpsertTriggerSql(
69+
func='INSERT INTO "baseapp_files_fileevent" ("content_type", "created", "created_by_id", "description", "file", "file_name", "file_size", "id", "modified", "name", "parent_content_type_id", "parent_object_id", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "pgh_operation", "updated") VALUES (OLD."content_type", OLD."created", OLD."created_by_id", OLD."description", OLD."file", OLD."file_name", OLD."file_size", OLD."id", OLD."modified", OLD."name", OLD."parent_content_type_id", OLD."parent_object_id", _pgh_attach_context(), NOW(), \'snapshot\', OLD."id", 3, OLD."updated"); RETURN NULL;',
70+
hash="ce527d470682a74377bb63ac788dc32f5d10a52f",
71+
operation="DELETE",
72+
pgid="pgtrigger_snapshot_delete_09e63",
73+
table="baseapp_files_file",
74+
when="AFTER",
75+
),
76+
),
77+
),
78+
]

baseapp-files/baseapp_files/models.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ class File(TimeStampedModel):
2929
parent_content_type = models.ForeignKey(
3030
ContentType,
3131
null=True,
32+
blank=True,
3233
on_delete=models.CASCADE,
3334
)
34-
parent_object_id = models.PositiveIntegerField(null=True)
35+
parent_object_id = models.PositiveIntegerField(null=True, blank=True)
3536
parent = GenericForeignKey("parent_content_type", "parent_object_id")
3637

3738
content_type = models.CharField(max_length=150, null=True, blank=True)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Generated by Django 4.2.3 on 2024-03-07 02:35
2+
3+
from django.db import migrations
4+
import pgtrigger.compiler
5+
import pgtrigger.migrations
6+
7+
8+
class Migration(migrations.Migration):
9+
dependencies = [
10+
("baseapp_pages", "0002_page_pageevent_page_snapshot_insert_and_more"),
11+
]
12+
13+
operations = [
14+
pgtrigger.migrations.RemoveTrigger(
15+
model_name="page",
16+
name="snapshot_insert",
17+
),
18+
pgtrigger.migrations.RemoveTrigger(
19+
model_name="page",
20+
name="snapshot_update",
21+
),
22+
pgtrigger.migrations.RemoveTrigger(
23+
model_name="page",
24+
name="snapshot_delete",
25+
),
26+
migrations.RemoveField(
27+
model_name="page",
28+
name="body_es",
29+
),
30+
migrations.RemoveField(
31+
model_name="page",
32+
name="body_pt",
33+
),
34+
migrations.RemoveField(
35+
model_name="page",
36+
name="title_es",
37+
),
38+
migrations.RemoveField(
39+
model_name="page",
40+
name="title_pt",
41+
),
42+
migrations.RemoveField(
43+
model_name="pageevent",
44+
name="body_es",
45+
),
46+
migrations.RemoveField(
47+
model_name="pageevent",
48+
name="body_pt",
49+
),
50+
migrations.RemoveField(
51+
model_name="pageevent",
52+
name="title_es",
53+
),
54+
migrations.RemoveField(
55+
model_name="pageevent",
56+
name="title_pt",
57+
),
58+
pgtrigger.migrations.AddTrigger(
59+
model_name="page",
60+
trigger=pgtrigger.compiler.Trigger(
61+
name="snapshot_insert",
62+
sql=pgtrigger.compiler.UpsertTriggerSql(
63+
func='INSERT INTO "baseapp_pages_pageevent" ("body_en", "created", "id", "modified", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "pgh_operation", "status", "title_en", "user_id") VALUES (NEW."body_en", NEW."created", NEW."id", NEW."modified", _pgh_attach_context(), NOW(), \'snapshot\', NEW."id", 1, NEW."status", NEW."title_en", NEW."user_id"); RETURN NULL;',
64+
hash="55f4f049fabff1f292e2afbddbdc19556943d88f",
65+
operation="INSERT",
66+
pgid="pgtrigger_snapshot_insert_f0c08",
67+
table="baseapp_pages_page",
68+
when="AFTER",
69+
),
70+
),
71+
),
72+
pgtrigger.migrations.AddTrigger(
73+
model_name="page",
74+
trigger=pgtrigger.compiler.Trigger(
75+
name="snapshot_update",
76+
sql=pgtrigger.compiler.UpsertTriggerSql(
77+
condition="WHEN (OLD.* IS DISTINCT FROM NEW.*)",
78+
func='INSERT INTO "baseapp_pages_pageevent" ("body_en", "created", "id", "modified", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "pgh_operation", "status", "title_en", "user_id") VALUES (NEW."body_en", NEW."created", NEW."id", NEW."modified", _pgh_attach_context(), NOW(), \'snapshot\', NEW."id", 2, NEW."status", NEW."title_en", NEW."user_id"); RETURN NULL;',
79+
hash="1f11b3150e1528b485ef21813b87803030118168",
80+
operation="UPDATE",
81+
pgid="pgtrigger_snapshot_update_845c1",
82+
table="baseapp_pages_page",
83+
when="AFTER",
84+
),
85+
),
86+
),
87+
pgtrigger.migrations.AddTrigger(
88+
model_name="page",
89+
trigger=pgtrigger.compiler.Trigger(
90+
name="snapshot_delete",
91+
sql=pgtrigger.compiler.UpsertTriggerSql(
92+
func='INSERT INTO "baseapp_pages_pageevent" ("body_en", "created", "id", "modified", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "pgh_operation", "status", "title_en", "user_id") VALUES (OLD."body_en", OLD."created", OLD."id", OLD."modified", _pgh_attach_context(), NOW(), \'snapshot\', OLD."id", 3, OLD."status", OLD."title_en", OLD."user_id"); RETURN NULL;',
93+
hash="7cdabf6238b162b8badd513fc5fe12428aada391",
94+
operation="DELETE",
95+
pgid="pgtrigger_snapshot_delete_caf3a",
96+
table="baseapp_pages_page",
97+
when="AFTER",
98+
),
99+
),
100+
),
101+
]

0 commit comments

Comments
 (0)