Skip to content

Commit 16f677f

Browse files
projects/django: example updates violate rules
1 parent 80e212d commit 16f677f

File tree

4 files changed

+39
-38
lines changed

4 files changed

+39
-38
lines changed

.github/workflows/django_ci.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ jobs:
3232
- name: Set up Atlas action
3333
uses: ariga/atlas-action/setup@master
3434
- name: Atlas Schema Lint
35-
uses: ariga/atlas-action/schema/lint@master
35+
uses: ariga/atlas-action/schema/lint@d1655a01682319057d894ec872d6ca4b82cd4eba
3636
with:
3737
working-directory: ./projects/django
38-
env: django
39-
dev-url: 'sqlite://?mode=memory&_fk=1'
40-
url: 'env://url'
38+
env: django

projects/django/atlas.hcl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ env "django" {
1313
}
1414

1515
lint {
16-
rule "hcl" "name" {
17-
src = [ "atlas.rule.hcl" ]
16+
rule "hcl" "error" {
17+
error = true
18+
src = [ "error.rule.hcl" ]
19+
}
20+
rule "hcl" "warning" {
21+
src = [ "warning.rule.hcl" ]
1822
}
1923
}

projects/django/atlas.rule.hcl renamed to projects/django/error.rule.hcl

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -92,36 +92,4 @@ rule "schema" "foreign-key-not-nullable" {
9292
}
9393
}
9494
}
95-
}
96-
97-
predicate "column" "postfix_id" {
98-
name {
99-
match = ".+_id$"
100-
}
101-
}
102-
103-
predicate "foreign_key" "postfix_id" {
104-
all {
105-
column {
106-
predicate = predicate.column.postfix_id
107-
}
108-
}
109-
}
110-
111-
rule "schema" "foreign-key-postfix-id" {
112-
description = "Foreign keys must have a column name ending with '_id'"
113-
table {
114-
match {
115-
predicate = predicate.table.in
116-
vars = {
117-
names = ["academie_department", "academie_student"]
118-
}
119-
}
120-
foreign_key {
121-
assert {
122-
predicate = predicate.foreign_key.postfix_id
123-
message = "Foreign key ${self.name} must have a column name ending with '_id'"
124-
}
125-
}
126-
}
12795
}

projects/django/warning.rule.hcl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
predicate "column" "postfix_id" {
2+
name {
3+
match = ".+_id$"
4+
}
5+
}
6+
7+
predicate "foreign_key" "postfix_id" {
8+
all {
9+
column {
10+
predicate = predicate.column.postfix_id
11+
}
12+
}
13+
}
14+
15+
rule "schema" "foreign-key-postfix-id" {
16+
description = "Foreign keys should have a column name ending with '_id'"
17+
table {
18+
match {
19+
predicate = predicate.table.in
20+
vars = {
21+
names = ["academie_department", "academie_student"]
22+
}
23+
}
24+
foreign_key {
25+
assert {
26+
predicate = predicate.foreign_key.postfix_id
27+
message = "Foreign key ${self.name} should have a column name ending with '_id'"
28+
}
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)