davidtran999 commited on
Commit
f45e06e
·
verified ·
1 Parent(s): 51779ea

Upload backend/core/migrations/0006_legal_documents.py with huggingface_hub

Browse files
backend/core/migrations/0006_legal_documents.py ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from django.db import migrations, models
2
+ import django.contrib.postgres.search
3
+ import django.contrib.postgres.indexes
4
+ import django.db.models.deletion
5
+
6
+
7
+ class Migration(migrations.Migration):
8
+
9
+ dependencies = [
10
+ ("core", "0005_conversation_models"),
11
+ ]
12
+
13
+ operations = [
14
+ migrations.CreateModel(
15
+ name="LegalDocument",
16
+ fields=[
17
+ (
18
+ "id",
19
+ models.AutoField(
20
+ auto_created=True,
21
+ primary_key=True,
22
+ serialize=False,
23
+ verbose_name="ID",
24
+ ),
25
+ ),
26
+ ("code", models.CharField(max_length=100, unique=True)),
27
+ ("title", models.CharField(max_length=500)),
28
+ (
29
+ "doc_type",
30
+ models.CharField(
31
+ choices=[
32
+ ("decision", "Decision"),
33
+ ("circular", "Circular"),
34
+ ("guideline", "Guideline"),
35
+ ("plan", "Plan"),
36
+ ("other", "Other"),
37
+ ],
38
+ default="other",
39
+ max_length=30,
40
+ ),
41
+ ),
42
+ ("summary", models.TextField(blank=True)),
43
+ ("issued_by", models.CharField(blank=True, max_length=200)),
44
+ ("issued_at", models.DateField(blank=True, null=True)),
45
+ ("source_file", models.CharField(max_length=500)),
46
+ ("source_url", models.URLField(blank=True, max_length=1000)),
47
+ ("page_count", models.IntegerField(blank=True, null=True)),
48
+ ("raw_text", models.TextField()),
49
+ ("metadata", models.JSONField(blank=True, default=dict)),
50
+ ("created_at", models.DateTimeField(auto_now_add=True)),
51
+ ("updated_at", models.DateTimeField(auto_now=True)),
52
+ (
53
+ "tsv_body",
54
+ django.contrib.postgres.search.SearchVectorField(
55
+ editable=False, null=True
56
+ ),
57
+ ),
58
+ ],
59
+ options={
60
+ "ordering": ["title"],
61
+ },
62
+ ),
63
+ migrations.CreateModel(
64
+ name="LegalSection",
65
+ fields=[
66
+ (
67
+ "id",
68
+ models.AutoField(
69
+ auto_created=True,
70
+ primary_key=True,
71
+ serialize=False,
72
+ verbose_name="ID",
73
+ ),
74
+ ),
75
+ ("section_code", models.CharField(max_length=120)),
76
+ ("section_title", models.CharField(blank=True, max_length=500)),
77
+ (
78
+ "level",
79
+ models.CharField(
80
+ choices=[
81
+ ("chapter", "Chapter"),
82
+ ("section", "Section"),
83
+ ("article", "Article"),
84
+ ("clause", "Clause"),
85
+ ("note", "Note"),
86
+ ("other", "Other"),
87
+ ],
88
+ default="other",
89
+ max_length=30,
90
+ ),
91
+ ),
92
+ ("order", models.PositiveIntegerField(db_index=True, default=0)),
93
+ ("page_start", models.IntegerField(blank=True, null=True)),
94
+ ("page_end", models.IntegerField(blank=True, null=True)),
95
+ ("content", models.TextField()),
96
+ ("excerpt", models.TextField(blank=True)),
97
+ ("metadata", models.JSONField(blank=True, default=dict)),
98
+ (
99
+ "tsv_body",
100
+ django.contrib.postgres.search.SearchVectorField(
101
+ editable=False, null=True
102
+ ),
103
+ ),
104
+ (
105
+ "embedding",
106
+ models.BinaryField(blank=True, editable=False, null=True),
107
+ ),
108
+ (
109
+ "document",
110
+ models.ForeignKey(
111
+ on_delete=django.db.models.deletion.CASCADE,
112
+ related_name="sections",
113
+ to="core.legaldocument",
114
+ ),
115
+ ),
116
+ ],
117
+ options={
118
+ "ordering": ["document", "order"],
119
+ "unique_together": {("document", "section_code", "order")},
120
+ },
121
+ ),
122
+ migrations.AddIndex(
123
+ model_name="legaldocument",
124
+ index=models.Index(fields=["doc_type"], name="core_legaldo_doc_typ_01ee44_idx"),
125
+ ),
126
+ migrations.AddIndex(
127
+ model_name="legaldocument",
128
+ index=models.Index(fields=["issued_at"], name="core_legaldo_issued__df806a_idx"),
129
+ ),
130
+ migrations.AddIndex(
131
+ model_name="legaldocument",
132
+ index=django.contrib.postgres.indexes.GinIndex(
133
+ fields=["tsv_body"], name="legal_document_tsv_idx"
134
+ ),
135
+ ),
136
+ migrations.AddIndex(
137
+ model_name="legalsection",
138
+ index=models.Index(fields=["document", "order"], name="core_legalse_documen_1cb98e_idx"),
139
+ ),
140
+ migrations.AddIndex(
141
+ model_name="legalsection",
142
+ index=models.Index(fields=["level"], name="core_legalse_level_e3a6a8_idx"),
143
+ ),
144
+ migrations.AddIndex(
145
+ model_name="legalsection",
146
+ index=django.contrib.postgres.indexes.GinIndex(
147
+ fields=["tsv_body"], name="legal_section_tsv_idx"
148
+ ),
149
+ ),
150
+ ]
151
+