@neralabs/rerail-pack-alembic 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/pack.json ADDED
@@ -0,0 +1,192 @@
1
+ {
2
+ "format": "rerail.rule-pack/v1",
3
+ "id": "alembic",
4
+ "name": "Alembic",
5
+ "category": "framework",
6
+ "covers": "Rerail's own Alembic rules, from the PostgreSQL, Alembic and SQLAlchemy docs, for migrations that deploy and roll back cleanly: concurrent index builds left in the migration's transaction, forked revision histories, ORM models imported into migrations and empty downgrades.",
7
+ "reason": "matches Alembic",
8
+ "match": {
9
+ "any": [
10
+ {
11
+ "dependencies": {
12
+ "ecosystem": "pypi",
13
+ "names": [
14
+ "alembic"
15
+ ]
16
+ }
17
+ },
18
+ {
19
+ "files": [
20
+ "**/alembic.ini"
21
+ ],
22
+ "label": "alembic.ini files"
23
+ }
24
+ ]
25
+ },
26
+ "rules": [
27
+ {
28
+ "id": "alembic-practice-concurrent-index-outside-autocommit",
29
+ "document": "rules/alembic-practice-concurrent-index-outside-autocommit.rerail",
30
+ "title": "Alembic practice: a concurrent index build or drop left in the migration's transaction",
31
+ "group": "Alembic practice",
32
+ "dimensions": {
33
+ "risk": "availability",
34
+ "layer": "migrations",
35
+ "severity": "high",
36
+ "hazard": "pg.concurrently-in-transaction"
37
+ },
38
+ "mode": "steer",
39
+ "on": true,
40
+ "examples": {
41
+ "caught": {
42
+ "path": "migrations/versions/b2c3d4e5f6a7_users_email_index.py",
43
+ "text": "\"\"\"add an index on users.email\"\"\"\nfrom alembic import op\n\nrevision = \"b2c3d4e5f6a7\"\ndown_revision = \"a1b2c3d4e5f6\"\nbranch_labels = None\ndepends_on = None\n\n\ndef upgrade():\n op.create_index(\"ix_users_email\", \"users\", [\"email\"], postgresql_concurrently=True)\n\n\ndef downgrade():\n op.drop_index(\"ix_users_email\", table_name=\"users\", postgresql_concurrently=True)\n"
44
+ },
45
+ "passes": {
46
+ "path": "migrations/versions/b2c3d4e5f6a7_users_email_index.py",
47
+ "text": "\"\"\"add an index on users.email\"\"\"\nfrom alembic import op\n\nrevision = \"b2c3d4e5f6a7\"\ndown_revision = \"a1b2c3d4e5f6\"\nbranch_labels = None\ndepends_on = None\n\n\ndef upgrade():\n with op.get_context().autocommit_block():\n op.create_index(\"ix_users_email\", \"users\", [\"email\"], postgresql_concurrently=True)\n\n\ndef downgrade():\n with op.get_context().autocommit_block():\n op.drop_index(\"ix_users_email\", table_name=\"users\", postgresql_concurrently=True)\n"
48
+ }
49
+ }
50
+ },
51
+ {
52
+ "id": "alembic-practice-multiple-heads",
53
+ "document": "rules/alembic-practice-multiple-heads.rerail",
54
+ "title": "Alembic practice: revisions that leave one migration directory with two heads",
55
+ "group": "Alembic practice",
56
+ "dimensions": {
57
+ "risk": "availability",
58
+ "layer": "migrations",
59
+ "severity": "high",
60
+ "hazard": "migrations.multiple-heads"
61
+ },
62
+ "mode": "steer",
63
+ "on": true,
64
+ "examples": {
65
+ "caught": {
66
+ "path": "migrations/versions/c2_add_orders.py",
67
+ "text": "\"\"\"add orders\"\"\"\nimport sqlalchemy as sa\nfrom alembic import op\n\nrevision = \"c2\"\ndown_revision = \"b1\"\nbranch_labels = None\ndepends_on = None\n\n\ndef upgrade():\n op.create_table(\"orders\", sa.Column(\"id\", sa.Integer(), primary_key=True))\n\n\ndef downgrade():\n pass\n",
68
+ "with": [
69
+ {
70
+ "path": "migrations/versions/b1_init.py",
71
+ "text": "\"\"\"init\"\"\"\nimport sqlalchemy as sa\nfrom alembic import op\n\nrevision = \"b1\"\ndown_revision = None\nbranch_labels = None\ndepends_on = None\n\n\ndef upgrade():\n op.create_table(\"users\", sa.Column(\"id\", sa.Integer(), primary_key=True))\n\n\ndef downgrade():\n pass\n"
72
+ },
73
+ {
74
+ "path": "migrations/versions/c1_add_email.py",
75
+ "text": "\"\"\"add users.email\"\"\"\nimport sqlalchemy as sa\nfrom alembic import op\n\nrevision = \"c1\"\ndown_revision = \"b1\"\nbranch_labels = None\ndepends_on = None\n\n\ndef upgrade():\n op.add_column(\"users\", sa.Column(\"email\", sa.String(255)))\n\n\ndef downgrade():\n pass\n"
76
+ }
77
+ ]
78
+ },
79
+ "passes": {
80
+ "path": "migrations/versions/c2_add_orders.py",
81
+ "text": "\"\"\"add orders\"\"\"\nimport sqlalchemy as sa\nfrom alembic import op\n\nrevision = \"c2\"\ndown_revision = \"c1\"\nbranch_labels = None\ndepends_on = None\n\n\ndef upgrade():\n op.create_table(\"orders\", sa.Column(\"id\", sa.Integer(), primary_key=True))\n\n\ndef downgrade():\n pass\n",
82
+ "with": [
83
+ {
84
+ "path": "migrations/versions/b1_init.py",
85
+ "text": "\"\"\"init\"\"\"\nimport sqlalchemy as sa\nfrom alembic import op\n\nrevision = \"b1\"\ndown_revision = None\nbranch_labels = None\ndepends_on = None\n\n\ndef upgrade():\n op.create_table(\"users\", sa.Column(\"id\", sa.Integer(), primary_key=True))\n\n\ndef downgrade():\n pass\n"
86
+ },
87
+ {
88
+ "path": "migrations/versions/c1_add_email.py",
89
+ "text": "\"\"\"add users.email\"\"\"\nimport sqlalchemy as sa\nfrom alembic import op\n\nrevision = \"c1\"\ndown_revision = \"b1\"\nbranch_labels = None\ndepends_on = None\n\n\ndef upgrade():\n op.add_column(\"users\", sa.Column(\"email\", sa.String(255)))\n\n\ndef downgrade():\n pass\n"
90
+ }
91
+ ]
92
+ }
93
+ }
94
+ },
95
+ {
96
+ "id": "alembic-practice-model-import-in-migration",
97
+ "document": "rules/alembic-practice-model-import-in-migration.rerail",
98
+ "title": "Alembic practice: a migration imports the application's ORM models",
99
+ "group": "Alembic practice",
100
+ "dimensions": {
101
+ "risk": "availability",
102
+ "layer": "migrations",
103
+ "severity": "high",
104
+ "hazard": "orm.model-in-migration"
105
+ },
106
+ "mode": "steer",
107
+ "on": true,
108
+ "examples": {
109
+ "caught": {
110
+ "path": "migrations/versions/b2_group_slug.py",
111
+ "text": "\"\"\"add groups.slug and fill it\"\"\"\nimport sqlalchemy as sa\nfrom alembic import op\nfrom sqlalchemy.orm import Session\n\nfrom app.models import Group\n\nrevision = \"b2\"\ndown_revision = \"b1\"\n\n\ndef upgrade():\n op.add_column(\"groups\", sa.Column(\"slug\", sa.String(80)))\n session = Session(bind=op.get_bind())\n for group in session.query(Group):\n group.slug = group.name.lower()\n session.commit()\n\n\ndef downgrade():\n op.drop_column(\"groups\", \"slug\")\n",
112
+ "with": [
113
+ {
114
+ "path": "app/models.py",
115
+ "text": "from sqlalchemy import String\nfrom sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column\n\n\nclass Base(DeclarativeBase):\n pass\n\n\nclass Group(Base):\n __tablename__ = \"groups\"\n id: Mapped[int] = mapped_column(primary_key=True)\n name: Mapped[str] = mapped_column(String(80))\n slug: Mapped[str | None] = mapped_column(String(80))\n"
116
+ }
117
+ ]
118
+ },
119
+ "passes": {
120
+ "path": "migrations/versions/b2_group_slug.py",
121
+ "text": "\"\"\"add groups.slug and fill it\"\"\"\nimport sqlalchemy as sa\nfrom alembic import op\n\nrevision = \"b2\"\ndown_revision = \"b1\"\n\ngroups = sa.table(\"groups\", sa.column(\"id\", sa.Integer), sa.column(\"name\", sa.String), sa.column(\"slug\", sa.String))\n\n\ndef upgrade():\n op.add_column(\"groups\", sa.Column(\"slug\", sa.String(80)))\n op.execute(groups.update().values(slug=sa.func.lower(groups.c.name)))\n\n\ndef downgrade():\n op.drop_column(\"groups\", \"slug\")\n",
122
+ "with": [
123
+ {
124
+ "path": "app/models.py",
125
+ "text": "from sqlalchemy import String\nfrom sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column\n\n\nclass Base(DeclarativeBase):\n pass\n\n\nclass Group(Base):\n __tablename__ = \"groups\"\n id: Mapped[int] = mapped_column(primary_key=True)\n name: Mapped[str] = mapped_column(String(80))\n slug: Mapped[str | None] = mapped_column(String(80))\n"
126
+ }
127
+ ]
128
+ }
129
+ }
130
+ },
131
+ {
132
+ "id": "alembic-practice-empty-downgrade",
133
+ "document": "rules/alembic-practice-empty-downgrade.rerail",
134
+ "title": "Alembic practice: a revision's downgrade() does nothing while its upgrade() changes the schema",
135
+ "group": "Alembic practice",
136
+ "dimensions": {
137
+ "risk": "correctness",
138
+ "layer": "migrations",
139
+ "severity": "medium",
140
+ "hazard": "pg.irreversible-migration"
141
+ },
142
+ "mode": "log",
143
+ "on": true,
144
+ "examples": {
145
+ "caught": {
146
+ "path": "migrations/versions/e5_add_email.py",
147
+ "text": "\"\"\"add users.email\"\"\"\nimport sqlalchemy as sa\nfrom alembic import op\n\nrevision = \"e5\"\ndown_revision = \"e4\"\nbranch_labels = None\ndepends_on = None\n\n\ndef upgrade():\n op.add_column(\"users\", sa.Column(\"email\", sa.String(255), nullable=True))\n\n\ndef downgrade():\n pass\n",
148
+ "with": [
149
+ {
150
+ "path": "migrations/versions/e1_add_c1.py",
151
+ "text": "\"\"\"add t1.c1\"\"\"\nimport sqlalchemy as sa\nfrom alembic import op\n\nrevision = \"e1\"\ndown_revision = None\nbranch_labels = None\ndepends_on = None\n\n\ndef upgrade():\n op.add_column(\"t1\", sa.Column(\"c1\", sa.Integer(), nullable=True))\n\n\ndef downgrade():\n op.drop_column(\"t1\", \"c1\")\n"
152
+ },
153
+ {
154
+ "path": "migrations/versions/e2_add_c2.py",
155
+ "text": "\"\"\"add t2.c2\"\"\"\nimport sqlalchemy as sa\nfrom alembic import op\n\nrevision = \"e2\"\ndown_revision = \"e1\"\nbranch_labels = None\ndepends_on = None\n\n\ndef upgrade():\n op.add_column(\"t2\", sa.Column(\"c2\", sa.Integer(), nullable=True))\n\n\ndef downgrade():\n op.drop_column(\"t2\", \"c2\")\n"
156
+ },
157
+ {
158
+ "path": "migrations/versions/e3_add_c3.py",
159
+ "text": "\"\"\"add t3.c3\"\"\"\nimport sqlalchemy as sa\nfrom alembic import op\n\nrevision = \"e3\"\ndown_revision = \"e2\"\nbranch_labels = None\ndepends_on = None\n\n\ndef upgrade():\n op.add_column(\"t3\", sa.Column(\"c3\", sa.Integer(), nullable=True))\n\n\ndef downgrade():\n op.drop_column(\"t3\", \"c3\")\n"
160
+ },
161
+ {
162
+ "path": "migrations/versions/e4_add_c4.py",
163
+ "text": "\"\"\"add t4.c4\"\"\"\nimport sqlalchemy as sa\nfrom alembic import op\n\nrevision = \"e4\"\ndown_revision = \"e3\"\nbranch_labels = None\ndepends_on = None\n\n\ndef upgrade():\n op.add_column(\"t4\", sa.Column(\"c4\", sa.Integer(), nullable=True))\n\n\ndef downgrade():\n op.drop_column(\"t4\", \"c4\")\n"
164
+ }
165
+ ]
166
+ },
167
+ "passes": {
168
+ "path": "migrations/versions/e5_add_email.py",
169
+ "text": "\"\"\"add users.email\"\"\"\nimport sqlalchemy as sa\nfrom alembic import op\n\nrevision = \"e5\"\ndown_revision = \"e4\"\nbranch_labels = None\ndepends_on = None\n\n\ndef upgrade():\n op.add_column(\"users\", sa.Column(\"email\", sa.String(255), nullable=True))\n\n\ndef downgrade():\n op.drop_column(\"users\", \"email\")\n",
170
+ "with": [
171
+ {
172
+ "path": "migrations/versions/e1_add_c1.py",
173
+ "text": "\"\"\"add t1.c1\"\"\"\nimport sqlalchemy as sa\nfrom alembic import op\n\nrevision = \"e1\"\ndown_revision = None\nbranch_labels = None\ndepends_on = None\n\n\ndef upgrade():\n op.add_column(\"t1\", sa.Column(\"c1\", sa.Integer(), nullable=True))\n\n\ndef downgrade():\n op.drop_column(\"t1\", \"c1\")\n"
174
+ },
175
+ {
176
+ "path": "migrations/versions/e2_add_c2.py",
177
+ "text": "\"\"\"add t2.c2\"\"\"\nimport sqlalchemy as sa\nfrom alembic import op\n\nrevision = \"e2\"\ndown_revision = \"e1\"\nbranch_labels = None\ndepends_on = None\n\n\ndef upgrade():\n op.add_column(\"t2\", sa.Column(\"c2\", sa.Integer(), nullable=True))\n\n\ndef downgrade():\n op.drop_column(\"t2\", \"c2\")\n"
178
+ },
179
+ {
180
+ "path": "migrations/versions/e3_add_c3.py",
181
+ "text": "\"\"\"add t3.c3\"\"\"\nimport sqlalchemy as sa\nfrom alembic import op\n\nrevision = \"e3\"\ndown_revision = \"e2\"\nbranch_labels = None\ndepends_on = None\n\n\ndef upgrade():\n op.add_column(\"t3\", sa.Column(\"c3\", sa.Integer(), nullable=True))\n\n\ndef downgrade():\n op.drop_column(\"t3\", \"c3\")\n"
182
+ },
183
+ {
184
+ "path": "migrations/versions/e4_add_c4.py",
185
+ "text": "\"\"\"add t4.c4\"\"\"\nimport sqlalchemy as sa\nfrom alembic import op\n\nrevision = \"e4\"\ndown_revision = \"e3\"\nbranch_labels = None\ndepends_on = None\n\n\ndef upgrade():\n op.add_column(\"t4\", sa.Column(\"c4\", sa.Integer(), nullable=True))\n\n\ndef downgrade():\n op.drop_column(\"t4\", \"c4\")\n"
186
+ }
187
+ ]
188
+ }
189
+ }
190
+ }
191
+ ]
192
+ }
package/package.json CHANGED
@@ -1,6 +1,38 @@
1
1
  {
2
2
  "name": "@neralabs/rerail-pack-alembic",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Rerail rule pack: Alembic migrations that fail at deploy, fork the revision history, import the application's models or cannot be rolled back.",
5
+ "keywords": [
6
+ "rerail",
7
+ "rerail-pack",
8
+ "coding-agent",
9
+ "rules",
10
+ "alembic",
11
+ "postgresql",
12
+ "python"
13
+ ],
14
+ "license": "Apache-2.0",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/neralabs/rerail.git",
18
+ "directory": "packs/alembic"
19
+ },
20
+ "files": [
21
+ "pack.json",
22
+ "rules",
23
+ "LICENSE",
24
+ "NOTICE",
25
+ "README.md"
26
+ ],
27
+ "peerDependencies": {
28
+ "@neralabs/rerail": ">=0.2.3-0"
29
+ },
30
+ "peerDependenciesMeta": {
31
+ "@neralabs/rerail": {
32
+ "optional": true
33
+ }
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ }
38
+ }
@@ -0,0 +1,134 @@
1
+ .policy "alembic-practice-concurrent-index-outside-autocommit" revision 1
2
+ .description "Run concurrent index builds and drops in Alembic migrations inside an autocommit block; PostgreSQL refuses CONCURRENTLY inside a transaction."
3
+ .language python
4
+ .mode steer
5
+ .scope include "**/*.py"
6
+ // Rerail's own rule, not a port. PostgreSQL: "a regular CREATE INDEX command can be performed within a transaction
7
+ // block, but CREATE INDEX CONCURRENTLY cannot" (CREATE INDEX; DROP INDEX says the same). Alembic runs each revision in
8
+ // a transaction on PostgreSQL, so `op.create_index(..., postgresql_concurrently=True)` left in it fails the deploy's
9
+ // migration with "CREATE INDEX CONCURRENTLY cannot run inside a transaction block". Alembic's
10
+ // `MigrationContext.autocommit_block()` exists for this DDL. Squawk's ban-concurrent-index-creation-in-transaction
11
+ // reads SQL files only; this rule reads Alembic's Python, follows helpers the steps call and the env.py that decides
12
+ // whether there is a transaction at all. It also guards alembic-practice-index-not-concurrent's steer: an agent told
13
+ // to build concurrently often adds only the keyword.
14
+ //
15
+ // Reported, in a revision's `upgrade()` or `downgrade()` (or a module-level function of the same file that a step
16
+ // calls outside an autocommit block):
17
+ // op.create_index("ix", "users", ["x"], postgresql_concurrently=True) reported
18
+ // op.drop_index("ix", table_name="users", postgresql_concurrently=True) reported
19
+ // with op.batch_alter_table("users") as batch_op:
20
+ // batch_op.create_index("ix", ["x"], postgresql_concurrently=True) reported (and batch_op.drop_index)
21
+ // with op.get_context().autocommit_block():
22
+ // ...
23
+ // op.create_index(..., postgresql_concurrently=True) reported: after the block, the
24
+ // revision's transaction is open again
25
+ // if _is_pg(conn): op.create_index(..., postgresql_concurrently=True) reported: PostgreSQL's own branch
26
+ // Left alone:
27
+ // with op.get_context().autocommit_block(): inside the block, at any depth (an
28
+ // op.create_index(..., postgresql_concurrently=True) `if` in it, a batch in it, a helper
29
+ // called from it); `<ctx>.autocommit_block()`
30
+ // on a context held in a local too
31
+ // postgresql_concurrently=False, absent, or an expression the rule cannot evaluate not concurrent (alembic-practice-
32
+ // index-not-concurrent's concern); True
33
+ // is read by value: the literal, or a
34
+ // module constant of this file or an
35
+ // imported one (lib/alembic's al_kw_ext)
36
+ // else: op.create_index(..., postgresql_concurrently=True) after `if _is_pg(conn):`, or under
37
+ // `if dialect.name == "sqlite":` another database ignores the keyword
38
+ // an env.py that runs its revisions with no transaction around them: `context.configure(...,
39
+ // transactional_ddl=False)` (by value), or an engine or connection with `isolation_level="AUTOCOMMIT"` in env.py
40
+ // or in the module env.py imports it from (lib/alembic's al_env_reads) nothing is reported in the revisions
41
+ // under that env.py's directory, nor in
42
+ // a revision under no env.py's directory
43
+ // (transaction_per_migration=True still
44
+ // opens one per revision: reported)
45
+ // revisions under tests/, files without `revision`/`down_revision`, an `op` that is not alembic.op.
46
+ // Gaps: raw SQL (`op.execute("CREATE INDEX CONCURRENTLY ...")`) is not read; the old `op.execute("COMMIT")` hack is
47
+ // not recognised (none in the corpus); helpers in another module, or two calls deep; an env.py outside the run (a
48
+ // rule run on the versions directory alone) is not seen.
49
+ // Corpus (8 Alembic repositories): 0 matches; every concurrent call there is wrapped. See the README's rule details.
50
+
51
+ #include "lib/alembic.rerail"
52
+
53
+ .violation ConcurrentIndexInTransaction(at: node, m: symbol) "`{m}` with CONCURRENTLY runs in the revision's transaction, which PostgreSQL refuses. Wrap it in `with op.get_context().autocommit_block():`; the block commits the steps before it, so run it last."
54
+
55
+ // ci_no_tx_env(e): env.py e runs its revisions outside any transaction, so CONCURRENTLY needs no autocommit block:
56
+ // `transactional_ddl=False` (a literal or a constant of env.py; an imported constant through lib/alembic's
57
+ // al_kw_ext), or an AUTOCOMMIT isolation level set in env.py or the module it imports its engine from (al_env_reads,
58
+ // by document: ci_autocommit_doc is each file's own).
59
+ .decl ci_no_tx_env(e: number)
60
+ ci_no_tx_env(e) :- ci_off_here(e).
61
+ ci_no_tx_env(e) :- ci_configure_at(e, t), al_kw_ext(e, t, "transactional_ddl", "false").
62
+ ci_no_tx_env(e) :- al_env_reads(e, d), ci_autocommit_doc(d).
63
+ .decl ci_off_here(e: number)
64
+ ci_off_here(e) :- al_env_configure(k), al_false_kw(k, "transactional_ddl"), docof(k, e).
65
+ .decl ci_configure_at(e: number, t: symbol)
66
+ ci_configure_at(e, t) :- al_env_configure(k), al_term(k, e, t).
67
+ .decl ci_autocommit_doc(d: number)
68
+ ci_autocommit_doc(d) :- call_arg(k, -1, "isolation_level", v), docof(k, d), unparen(v, u), str(u, s), l = @lower(s),
69
+ l = "autocommit".
70
+ // ci_no_transaction(d): revision d runs without a transaction: its env.py turns transactional DDL off, or it sits
71
+ // under no env.py of the run and one env.py of the run turns it off.
72
+ .decl ci_no_transaction(d: number)
73
+ // The tree is lib/alembic's al_env_tree (a repository can hold several Alembic trees, as Netflix/dispatch's core and
74
+ // tenant schemas do).
75
+ ci_no_transaction(d) :- al_env_tree(d, e), ci_no_tx_env(e).
76
+ ci_no_transaction(d) :- al_migration_doc(d), !al_in_some_tree(d), ci_no_tx_env(_).
77
+ // ci_in_transaction(c): node c runs in a step's transaction: inside a step and not in an autocommit block, or inside a
78
+ // module-level helper (same file) that a step calls from outside an autocommit block, and not in a block of its own.
79
+ .decl ci_in_transaction(c: node)
80
+ ci_in_transaction(c) :- al_step(f, _), within(c, f), !al_in_autocommit(c).
81
+ ci_in_transaction(c) :- al_step(f, _), kind(k, "call"), within(k, f), !al_in_autocommit(k), field(k, "function", fn),
82
+ kind(fn, "identifier"), text(fn, x), kind(g, "function_definition"), def_name(g, x), nearest(g, s, scope),
83
+ kind(s, "module"), docof(g, d), docof(f, d), g != f, within(c, g), !al_in_autocommit(c).
84
+ // ci_live(c, m, d, t): index operation m (c, of term t) of revision d (outside test code) runs in a step's transaction,
85
+ // in a branch its own file does not rule out for PostgreSQL.
86
+ .decl ci_live(c: node, m: symbol, d: number, t: symbol)
87
+ ci_live(c, m, d, t) :- al_call(c, m, _), (m = "create_index" ; m = "drop_index"), docof(c, d), al_migration_doc(d),
88
+ !al_test_doc(d), ci_in_transaction(c), !al_non_pg(c), al_term(c, d, t).
89
+
90
+ // The finding joins the call's own facts to what crosses files: the flag's imported constant (al_kw_ext), a test
91
+ // function of another module (al_np_ext), and the env.py of the revision's tree (ci_no_transaction).
92
+ ConcurrentIndexInTransaction(c, m) :- ci_live(c, m, d, t), (al_true_kw(c, "postgresql_concurrently") ;
93
+ al_kw_ext(d, t, "postgresql_concurrently", "true")), !al_np_ext(d, t), !ci_no_transaction(d).
94
+
95
+ // The cases, `upstream/alembic-practice/authored/alembic-practice-concurrent-index-outside-autocommit/`, read as one
96
+ // repository: each line ending in `# caught` is reported, and no other line. `autocommit_env/` is a second Alembic tree
97
+ // whose env.py turns transactional DDL off: silent beside the reported tree, and alone.
98
+ .test cases exactly
99
+ .fixture "app/__init__.py" from "../upstream/alembic-practice/authored/alembic-practice-concurrent-index-outside-autocommit/app/__init__.py"
100
+ .fixture "autocommit_env/migrations/env.py" from "../upstream/alembic-practice/authored/alembic-practice-concurrent-index-outside-autocommit/autocommit_env/migrations/env.py"
101
+ .fixture "autocommit_env/migrations/versions/a1_users.py" from "../upstream/alembic-practice/authored/alembic-practice-concurrent-index-outside-autocommit/autocommit_env/migrations/versions/a1_users.py"
102
+ .fixture "autocommit_env/elsewhere/a2_orphan.py" from "../upstream/alembic-practice/authored/alembic-practice-concurrent-index-outside-autocommit/autocommit_env/elsewhere/a2_orphan.py"
103
+ .fixture "autocommit_iso/db.py" from "../upstream/alembic-practice/authored/alembic-practice-concurrent-index-outside-autocommit/autocommit_iso/db.py"
104
+ .fixture "autocommit_iso/migrations/env.py" from "../upstream/alembic-practice/authored/alembic-practice-concurrent-index-outside-autocommit/autocommit_iso/migrations/env.py"
105
+ .fixture "autocommit_iso/migrations/versions/i1_users.py" from "../upstream/alembic-practice/authored/alembic-practice-concurrent-index-outside-autocommit/autocommit_iso/migrations/versions/i1_users.py"
106
+ .fixture "app/db.py" from "../upstream/alembic-practice/authored/alembic-practice-concurrent-index-outside-autocommit/app/db.py"
107
+ .fixture "app/search.py" from "../upstream/alembic-practice/authored/alembic-practice-concurrent-index-outside-autocommit/app/search.py"
108
+ .fixture "migrations/env.py" from "../upstream/alembic-practice/authored/alembic-practice-concurrent-index-outside-autocommit/migrations/env.py"
109
+ .fixture "migrations/versions/c1_users.py" from "../upstream/alembic-practice/authored/alembic-practice-concurrent-index-outside-autocommit/migrations/versions/c1_users.py"
110
+ .fixture "migrations/versions/c2_batch_and_dialects.py" from "../upstream/alembic-practice/authored/alembic-practice-concurrent-index-outside-autocommit/migrations/versions/c2_batch_and_dialects.py"
111
+ .fixture "migrations/versions/c4_helpers.py" from "../upstream/alembic-practice/authored/alembic-practice-concurrent-index-outside-autocommit/migrations/versions/c4_helpers.py"
112
+ .fixture "migrations/versions/c5_constants.py" from "../upstream/alembic-practice/authored/alembic-practice-concurrent-index-outside-autocommit/migrations/versions/c5_constants.py"
113
+ .fixture "migrations/versions/c3_not_alembic.py" from "../upstream/alembic-practice/authored/alembic-practice-concurrent-index-outside-autocommit/migrations/versions/c3_not_alembic.py"
114
+ .fixture "tests/migrations/versions/t1_fixture.py" from "../upstream/alembic-practice/authored/alembic-practice-concurrent-index-outside-autocommit/tests/migrations/versions/t1_fixture.py"
115
+ .expect _ at "migrations/versions/c1_users.py":12
116
+ .expect _ at "migrations/versions/c1_users.py":13
117
+ .expect _ at "migrations/versions/c1_users.py":20
118
+ .expect _ at "migrations/versions/c1_users.py":30
119
+ .expect _ at "migrations/versions/c1_users.py":40
120
+ .expect _ at "migrations/versions/c1_users.py":44
121
+ .expect _ at "migrations/versions/c2_batch_and_dialects.py":15
122
+ .expect _ at "migrations/versions/c2_batch_and_dialects.py":16
123
+ .expect _ at "migrations/versions/c2_batch_and_dialects.py":25
124
+ .expect _ at "migrations/versions/c2_batch_and_dialects.py":50
125
+ .expect _ at "migrations/versions/c4_helpers.py":24
126
+ .expect _ at "migrations/versions/c5_constants.py":15
127
+ .expect _ at "migrations/versions/c5_constants.py":16
128
+ .end
129
+
130
+ .test autocommit_env exactly
131
+ .fixture "migrations/env.py" from "../upstream/alembic-practice/authored/alembic-practice-concurrent-index-outside-autocommit/autocommit_env/migrations/env.py"
132
+ .fixture "migrations/versions/a1_users.py" from "../upstream/alembic-practice/authored/alembic-practice-concurrent-index-outside-autocommit/autocommit_env/migrations/versions/a1_users.py"
133
+ .fixture "elsewhere/a2_orphan.py" from "../upstream/alembic-practice/authored/alembic-practice-concurrent-index-outside-autocommit/autocommit_env/elsewhere/a2_orphan.py"
134
+ .end
@@ -0,0 +1,181 @@
1
+ .policy "alembic-practice-empty-downgrade" revision 1
2
+ .description "Write the reverse operations in an Alembic revision's downgrade(), or raise if it is irreversible, where the migration tree implements its downgrades."
3
+ .language python
4
+ .mode log
5
+ .scope include "**/*.py"
6
+ // Rerail's own rule, not a port. A revision whose upgrade() changes the schema while its downgrade() does nothing:
7
+ // `alembic downgrade` runs the empty function, reports success and moves the version table back while the schema keeps
8
+ // upgrade()'s changes: the database no longer matches the revision it records, the next `alembic upgrade` can fail on
9
+ // what is already there (the column already exists, the constraint is already gone), and the
10
+ // rollback path the team relies on is broken. The Alembic cookbook expects a migration to reach the finished schema
11
+ // "and back again"; pytest-alembic's test_up_down_consistency only checks that downgrades run, so it passes this.
12
+ // It reads a migration tree as the revision files of one directory (al_rev_dir: `core/versions` and `tenant/versions`
13
+ // are two trees; test code is left out) and judges a revision against that tree's convention.
14
+ // Reported, at `def downgrade():`:
15
+ // def upgrade(): op.add_column("users", ...) downgrade() is only `pass`, `...`, a bare `return`, or those,
16
+ // def downgrade(): pass and Alembic's autogenerate markers (`# ### commands ... ###`)
17
+ // with op.batch_alter_table("orders") as b: a batch operation, or one in a module-level helper that
18
+ // b.create_index(...) upgrade() calls, is a schema operation too
19
+ // when the revision's tree implements its downgrades: of the tree's counted revisions (one parent, a schema operation in
20
+ // upgrade(), and not left alone below), at least 4 in 5 have a downgrade() that does something. A tree needs 5 counted
21
+ // revisions before the share can reach 80% with one empty downgrade. 80%: in the 8 Alembic repositories of the corpus
22
+ // every tree is at 98% or more (superset 169 of 171, dispatch's tenant tree 136 of 137, the others 100%), so the
23
+ // threshold only silences small or young trees where empty downgrades are the habit (3 of 4 is 75%: silent).
24
+ // A schema operation is any Alembic operation (al_call: `op.m(...)` or a batch handle's) other than execute, bulk_insert,
25
+ // f, get_bind, get_context, batch_alter_table, inline_literal, invoke, run_async and implementation_for.
26
+ // Left alone (and not counted):
27
+ // down_revision = ("a1", "b2") a merge revision
28
+ // def upgrade(): op.execute("UPDATE ...") an upgrade() that is empty or data-only
29
+ // def downgrade(): raise NotImplementedError(...) a downgrade that raises (or does anything at all)
30
+ // if not inspector.has_table("t"): op.create_table an upgrade() that reads the live schema first (sa.inspect,
31
+ // Inspector.from_engine, get_columns, has_table, superset's
32
+ // table_has_column ...): an idempotent repair, which a second
33
+ // upgrade after the empty downgrade reruns without error
34
+ // def downgrade(): a downgrade() with a comment of its own (not Alembic's
35
+ // # the down revision already allows NULL here markers, and not one that starts TODO, FIXME or XXX) or a
36
+ // pass docstring: a recorded decision that the down revision's
37
+ // schema already accepts this one
38
+ // revisions in test code
39
+ // Gaps: schema changes made outside Alembic's op (raw DDL in op.execute, a project's own add_columns wrapper,
40
+ // sqlalchemy-searchable's sync_trigger) are not schema operations here, so such a revision is neither reported nor
41
+ // counted; a downgrade() made of other no-op statements (`print(...)`, a log call) counts as implemented; an explaining
42
+ // comment silences the rule whatever else it says; in a tree of fewer than 10 counted revisions, two empty downgrades
43
+ // put it under 80% and silence the rule for the whole tree (by design: the habit is then the tree's own).
44
+ // Corpus (8 Alembic repositories): 3 matches, all read, all real; see the README's rule details.
45
+
46
+ #include "lib/alembic.rerail"
47
+
48
+ .violation EmptyDowngrade(at: node, k: number, n: number) "This downgrade() does nothing while upgrade() changes the schema, and {k} of {n} revisions here implement theirs. Reverse upgrade() here, or raise if it cannot be undone. Skip if you never downgrade."
49
+
50
+ // ---- the revision's parts ----------------------------------------------------------------------------------------
51
+ // ed_non_op(m): an Alembic operation that changes no schema object.
52
+ .decl ed_non_op(m: symbol)
53
+ ed_non_op("execute"). ed_non_op("bulk_insert"). ed_non_op("f"). ed_non_op("get_bind"). ed_non_op("get_context").
54
+ ed_non_op("batch_alter_table"). ed_non_op("inline_literal"). ed_non_op("invoke"). ed_non_op("run_async").
55
+ ed_non_op("implementation_for").
56
+ // ed_schema_up(d): revision d's upgrade() (or a module-level helper it calls) runs a schema operation.
57
+ .decl ed_schema_up(d: number)
58
+ ed_schema_up(d) :- al_step(f, "upgrade"), al_call(c, m, _), !ed_non_op(m), al_in_step(c, f), docof(f, d).
59
+ // ed_merge(d): revision d merges two or more parents (`down_revision` is a tuple or list).
60
+ .decl ed_merge(d: number)
61
+ ed_merge(d) :- al_top_assign(d, "down_revision", v), (kind(v, "tuple") ; kind(v, "list")).
62
+ // ed_reflect_name(x): a call named x reads the live schema: SQLAlchemy's inspector and the helpers projects wrap it in.
63
+ .decl ed_reflect_name(x: symbol)
64
+ ed_reflect_name("inspect"). ed_reflect_name("from_engine"). ed_reflect_name("get_table_names").
65
+ ed_reflect_name("has_table"). ed_reflect_name("get_columns"). ed_reflect_name("get_indexes").
66
+ ed_reflect_name("get_unique_constraints"). ed_reflect_name("get_foreign_keys"). ed_reflect_name("get_pk_constraint").
67
+ ed_reflect_name("get_check_constraints"). ed_reflect_name("has_index"). ed_reflect_name("has_column").
68
+ ed_reflect_name("table_has_column"). ed_reflect_name("table_has_index"). ed_reflect_name("table_exists").
69
+ ed_reflect_name("column_exists"). ed_reflect_name("index_exists"). ed_reflect_name("constraint_exists").
70
+ ed_reflect_name("get_table_column").
71
+ // ed_reflects(d): revision d's upgrade() reads the live schema before it changes it: an idempotent repair.
72
+ .decl ed_reflects(d: number)
73
+ ed_reflects(d) :- al_step(f, "upgrade"), al_in_step(c, f), kind(c, "call"), field(c, "function", fn),
74
+ ed_callee_name(fn, x), ed_reflect_name(x), docof(f, d).
75
+ .decl ed_callee_name(fn: node, x: symbol)
76
+ ed_callee_name(fn, x) :- kind(fn, "identifier"), text(fn, x).
77
+ ed_callee_name(fn, x) :- attr_of(fn, _, x).
78
+ // ed_filler(s): a statement that does nothing: `pass`, `...`, a bare `return`, or a lone string literal (a docstring).
79
+ .decl ed_filler(s: node)
80
+ ed_filler(s) :- kind(s, "pass_statement").
81
+ ed_filler(s) :- kind(s, "expression_statement"), child(s, e, 0), !child(s, _, 1), kind(e, "ellipsis").
82
+ ed_filler(s) :- kind(s, "return_statement"), text(s, "return").
83
+ ed_filler(s) :- doc_stmt(s, _).
84
+ // ed_does_something(g): downgrade g's body holds a statement other than filler (a raise, a call, an assignment ...).
85
+ .decl ed_does_something(g: node)
86
+ ed_does_something(g) :- al_step(g, "downgrade"), field(g, "body", b), body_stmt(b, s, _), !ed_filler(s).
87
+ // ed_explained(g): downgrade g carries its author's own comment below its `def` line (not Alembic's `# ### ... ###`
88
+ // markers, not a `# noqa` on the def line, and not a TODO, FIXME or XXX note, which records no decision) or a docstring.
89
+ .decl ed_explained(g: node)
90
+ ed_explained(g) :- al_step(g, "downgrade"), kind(cm, "comment"), within(cm, g), line(cm, l), line(g, lg), l > lg,
91
+ text(cm, x), !prefix("# ###", x), y = @lower(@replace_all(x, "^#\\s*", "")), !prefix("todo", y),
92
+ !prefix("fixme", y), !prefix("xxx", y).
93
+ ed_explained(g) :- al_step(g, "downgrade"), docstring(g, _).
94
+ // ed_counted(d, p, g): revision d in tree p, with downgrade g, is one the tree's convention is measured on.
95
+ .decl ed_counted(d: number, p: symbol, g: node)
96
+ // A downgrade() that does nothing is excused (and not counted) when upgrade() reads the live schema first or the
97
+ // downgrade explains itself.
98
+ .decl ed_excused(d: number, g: node)
99
+ ed_excused(d, g) :- al_step(g, "downgrade"), docof(g, d), !ed_does_something(g), (ed_reflects(d) ; ed_explained(g)).
100
+ ed_counted(d, p, g) :- al_rev_dir(d, p), !ed_merge(d), ed_schema_up(d), al_step(g, "downgrade"), docof(g, d),
101
+ !ed_excused(d, g).
102
+ .decl ed_empty(d: number, p: symbol, g: node)
103
+ ed_empty(d, p, g) :- ed_counted(d, p, g), !ed_does_something(g).
104
+ // ed_tree(p, k, n): tree p has n counted revisions, k of them with a downgrade that does something. It counts the
105
+ // revision files of a directory, so it spans files on purpose (cross_file): each file states its own counted
106
+ // downgrade by the directory path and the downgrade's term (ed_counted_at, ed_doing_at), and the tree's counts hold
107
+ // paths and numbers alone.
108
+ .decl ed_counted_at(d: number, p: symbol, g: symbol)
109
+ ed_counted_at(d, p, gt) :- ed_counted(d, p, g), al_term(g, d, gt).
110
+ .decl ed_doing_at(d: number, p: symbol, g: symbol)
111
+ ed_doing_at(d, p, gt) :- ed_counted(d, p, g), ed_does_something(g), al_term(g, d, gt).
112
+ .decl ed_tree(p: symbol, k: number, n: number) cross_file
113
+ ed_tree(p, k, n) :- ed_counted_at(_, p, _), n = count : { ed_counted_at(_, p, _) },
114
+ k = count : { ed_doing_at(_, p, _) }.
115
+
116
+ EmptyDowngrade(g, k, n) :- ed_empty(_, p, g), ed_tree(p, k, n), n >= 5, k * 5 >= n * 4.
117
+
118
+ // The cases, `upstream/alembic-practice/authored/alembic-practice-empty-downgrade/`, read as one repository: each line
119
+ // ending in `# caught` is reported, and no other line.
120
+ .test cases exactly
121
+ .fixture "app/migrations/versions/c1_add_email.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/c1_add_email.py"
122
+ .fixture "app/migrations/versions/c2_batch_index.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/c2_batch_index.py"
123
+ .fixture "app/migrations/versions/c3_helper.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/c3_helper.py"
124
+ .fixture "app/migrations/versions/c4_fk.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/c4_fk.py"
125
+ .fixture "app/migrations/versions/c5_return.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/c5_return.py"
126
+ .fixture "app/migrations/versions/c6_todo.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/c6_todo.py"
127
+ .fixture "app/migrations/versions/g01_add_c1.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/grown/g01_add_c1.py"
128
+ .fixture "app/migrations/versions/g02_add_c2.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/grown/g02_add_c2.py"
129
+ .fixture "app/migrations/versions/g03_add_c3.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/grown/g03_add_c3.py"
130
+ .fixture "app/migrations/versions/g04_add_c4.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/grown/g04_add_c4.py"
131
+ .fixture "app/migrations/versions/g05_add_c5.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/grown/g05_add_c5.py"
132
+ .fixture "app/migrations/versions/g06_add_c6.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/grown/g06_add_c6.py"
133
+ .fixture "app/migrations/versions/g07_add_c7.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/grown/g07_add_c7.py"
134
+ .fixture "app/migrations/versions/g08_add_c8.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/grown/g08_add_c8.py"
135
+ .fixture "app/migrations/versions/g09_add_c9.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/grown/g09_add_c9.py"
136
+ .fixture "app/migrations/versions/g10_add_c10.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/grown/g10_add_c10.py"
137
+ .fixture "app/migrations/versions/g11_add_c11.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/grown/g11_add_c11.py"
138
+ .fixture "app/migrations/versions/g12_add_c12.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/grown/g12_add_c12.py"
139
+ .fixture "app/migrations/versions/g13_add_c13.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/grown/g13_add_c13.py"
140
+ .fixture "app/migrations/versions/g14_add_c14.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/grown/g14_add_c14.py"
141
+ .fixture "app/migrations/versions/g15_add_c15.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/grown/g15_add_c15.py"
142
+ .fixture "app/migrations/versions/g16_add_c16.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/grown/g16_add_c16.py"
143
+ .fixture "app/migrations/versions/g17_add_c17.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/grown/g17_add_c17.py"
144
+ .fixture "app/migrations/versions/g18_add_c18.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/grown/g18_add_c18.py"
145
+ .fixture "app/migrations/versions/g19_add_c19.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/grown/g19_add_c19.py"
146
+ .fixture "app/migrations/versions/g20_add_c20.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/grown/g20_add_c20.py"
147
+ .fixture "app/migrations/versions/g21_add_c21.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/grown/g21_add_c21.py"
148
+ .fixture "app/migrations/versions/g22_add_c22.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/grown/g22_add_c22.py"
149
+ .fixture "app/migrations/versions/g23_add_c23.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/grown/g23_add_c23.py"
150
+ .fixture "app/migrations/versions/g24_add_c24.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/grown/g24_add_c24.py"
151
+ .fixture "app/migrations/versions/n1_raise.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/n1_raise.py"
152
+ .fixture "app/migrations/versions/n2_merge.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/n2_merge.py"
153
+ .fixture "app/migrations/versions/n3_data_only.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/n3_data_only.py"
154
+ .fixture "app/migrations/versions/n4_empty.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/n4_empty.py"
155
+ .fixture "app/migrations/versions/n5_repair.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/n5_repair.py"
156
+ .fixture "app/migrations/versions/n6_explained.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/n6_explained.py"
157
+ .fixture "app/migrations/versions/n7_docstring.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/n7_docstring.py"
158
+ .fixture "app/migrations/versions/n8_helper_downgrade.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/app/migrations/versions/n8_helper_downgrade.py"
159
+ .fixture "legacy/alembic/versions/l1.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/legacy/alembic/versions/l1.py"
160
+ .fixture "legacy/alembic/versions/l2.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/legacy/alembic/versions/l2.py"
161
+ .fixture "legacy/alembic/versions/l3.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/legacy/alembic/versions/l3.py"
162
+ .fixture "legacy/alembic/versions/l4.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/legacy/alembic/versions/l4.py"
163
+ .fixture "tests/migrations/versions/x1.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/tests/migrations/versions/x1.py"
164
+ .fixture "tests/migrations/versions/x2.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/tests/migrations/versions/x2.py"
165
+ .fixture "tests/migrations/versions/x3.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/tests/migrations/versions/x3.py"
166
+ .fixture "tests/migrations/versions/x4.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/tests/migrations/versions/x4.py"
167
+ .fixture "tests/migrations/versions/x5.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/tests/migrations/versions/x5.py"
168
+ .fixture "tests/migrations/versions/x6.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/tests/migrations/versions/x6.py"
169
+ .fixture "tiny/alembic/versions/s1.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/tiny/alembic/versions/s1.py"
170
+ .fixture "tiny/alembic/versions/s2.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/tiny/alembic/versions/s2.py"
171
+ .fixture "tiny/alembic/versions/s3.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/tiny/alembic/versions/s3.py"
172
+ .fixture "tiny/alembic/versions/s4.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/tiny/alembic/versions/s4.py"
173
+ .fixture "tiny/alembic/versions/s5.py" from "../upstream/alembic-practice/authored/alembic-practice-empty-downgrade/tiny/alembic/versions/s5.py"
174
+ .expect _ at "app/migrations/versions/c1_add_email.py":15
175
+ .expect _ at "app/migrations/versions/c2_batch_index.py":16
176
+ .expect _ at "app/migrations/versions/c3_helper.py":20
177
+ .expect _ at "app/migrations/versions/c4_fk.py":15
178
+ .expect _ at "app/migrations/versions/c5_return.py":15
179
+ .expect _ at "app/migrations/versions/c6_todo.py":15
180
+ .expect _ at "tiny/alembic/versions/s5.py":15
181
+ .end