You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// the file context which contains other statements in that file in case you need them
18
18
file_context:&'aAnalysedFileContext,
19
19
}
20
+
21
+
pubstructAnalysedFileContext<'a> {
22
+
// all other statements in this file
23
+
puball_stmts:&'aVec<pgt_query::NodeEnum>,
24
+
// total count of statements in this file
25
+
pubstmt_count:usize,
26
+
// all statements before the currently analysed one
27
+
pubprevious_stmts:Vec<&'apgt_query::NodeEnum>,
28
+
}
20
29
```
21
30
22
31
In squawk, you will see:
@@ -41,27 +50,23 @@ LEARNINGS:
41
50
- RuleDiagnostic methods: `detail(span, msg)` takes two parameters, `note(msg)` takes only one parameter
42
51
- To check Postgres version: access `ctx.schema_cache().is_some_and(|sc| sc.version.major_version)` which gives e.g. 17
43
52
- NEVER skip anything, or use a subset of something. ALWAYS do the full thing. For example, copy the entire non-volatile functions list from Squawk, not just a subset.
53
+
- If you are missing features from our context to be able to properly implement a rule, DO NOT DO IT. Instead, add that rule to the NEEDS FEATURES list below.
44
54
- Remember to run `just gen-lint` after creating a new rule to generate all necessary files
45
55
46
56
Please update the list below with the rules that we need to migrate, and the ones that are already migrated. Keep the list up-to-date.
47
57
58
+
NEEDS FEATURES:
59
+
48
60
TODO:
49
-
- ban_concurrent_index_creation_in_transaction
50
-
- changing_column_type
51
-
- constraint_missing_not_valid
52
-
- disallow_unique_constraint
53
-
- prefer_big_int
54
-
- prefer_bigint_over_int
55
-
- prefer_bigint_over_smallint
56
-
- prefer_identity
57
-
- prefer_robust_stmts
58
61
- prefer_text_field
59
62
- prefer_timestamptz
60
63
- renaming_column
61
64
- renaming_table
62
65
- require_concurrent_index_creation
63
66
- require_concurrent_index_deletion
64
67
- transaction_nesting
68
+
- disallow_unique_constraint
69
+
- prefer_robust_stmts
65
70
66
71
DONE:
67
72
- adding_field_with_default ✓ (ported from Squawk)
@@ -70,9 +75,16 @@ DONE:
70
75
- adding_primary_key_constraint ✓ (ported from Squawk)
71
76
- adding_required_field (already exists in pgt_analyser)
72
77
- ban_char_field ✓ (ported from Squawk)
78
+
- ban_concurrent_index_creation_in_transaction ✓ (ported from Squawk)
73
79
- ban_drop_column (already exists in pgt_analyser)
80
+
- changing_column_type ✓ (ported from Squawk)
81
+
- constraint_missing_not_valid ✓ (ported from Squawk)
74
82
- ban_drop_database (already exists in pgt_analyser, as bad_drop_database in squawk)
75
83
- ban_drop_not_null (already exists in pgt_analyser)
76
84
- ban_drop_table (already exists in pgt_analyser)
85
+
- prefer_big_int ✓ (ported from Squawk)
86
+
- prefer_bigint_over_int ✓ (ported from Squawk)
87
+
- prefer_bigint_over_smallint ✓ (ported from Squawk)
if stmt.concurrent && ctx.file_context().stmt_count > 1{
41
+
diagnostics.push(RuleDiagnostic::new(
42
+
rule_category!(),
43
+
None,
44
+
markup!{
45
+
"CREATE INDEX CONCURRENTLY cannot be used inside a transaction block."
46
+
}
47
+
).detail(None,"Run CREATE INDEX CONCURRENTLY outside of a transaction. Migration tools usually run in transactions, so you may need to run this statement in its own migration or manually."));
0 commit comments