|
21 | 21 |
|
22 | 22 | from alembic import op
|
23 | 23 |
|
24 |
| -from warehouse.packaging.models import Project |
| 24 | +# from warehouse.packaging.models import Project |
25 | 25 |
|
26 | 26 | revision = "c978a4eaa0f6"
|
27 | 27 | down_revision = "56b3ef8e8af3"
|
@@ -60,17 +60,20 @@ def upgrade():
|
60 | 60 | ),
|
61 | 61 | )
|
62 | 62 |
|
| 63 | + # NOTE: Commenting out the following to avoid failing other migrations during tests. |
| 64 | + # Migration ran successfully in production on 2024-04-17 |
| 65 | + |
63 | 66 | # Data migration to set the related_name for existing rows.
|
64 |
| - bind = op.get_bind() |
65 |
| - session = sa.orm.Session(bind=bind) |
66 |
| - # Get all Projects with Observations |
67 |
| - projects_query = sa.select(Project).where(Project.observations.any()) |
68 |
| - # For each, set the `related_name` to the related Project's model name |
69 |
| - for project in session.scalars(projects_query): |
70 |
| - for observation in project.observations: |
71 |
| - observation.related_name = repr(project) |
72 |
| - session.add(observation) |
73 |
| - session.commit() |
| 67 | + # bind = op.get_bind() |
| 68 | + # session = sa.orm.Session(bind=bind) |
| 69 | + # # Get all Projects with Observations |
| 70 | + # projects_query = sa.select(Project).where(Project.observations.any()) |
| 71 | + # # For each, set the `related_name` to the related Project's model name |
| 72 | + # for project in session.scalars(projects_query): |
| 73 | + # for observation in project.observations: |
| 74 | + # observation.related_name = repr(project) |
| 75 | + # session.add(observation) |
| 76 | + # session.commit() |
74 | 77 |
|
75 | 78 | # Flip the nullable flag to False
|
76 | 79 | op.alter_column("project_observations", "related_name", nullable=False)
|
|
0 commit comments