Skip to content

Commit 8fd165b

Browse files
authored
Merge pull request #193 from lsst-sqre:tickets/DM-51816
DM-51816: Stop distinguishing collaborations from authors
2 parents ddd9cf0 + 927beca commit 8fd165b

File tree

12 files changed

+77
-226
lines changed

12 files changed

+77
-226
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
<!-- scriv-insert-here -->
44

5+
<a id='changelog-0.17.0'></a>
6+
7+
## 0.17.0 (2025-07-15)
8+
9+
### Backwards-incompatible changes
10+
11+
- Dropped the `collaboration` table from the database schema and removed related code from the application. Originally in Ook we wanted to treat human authors separate from pseudo authors in order to make building out a staff directory easier. However, working against the grain of authordb.yaml (the canonical source for Rubin author data) has proven to be difficult. Now collaborations/collective authors will appear in the `/authors/` endpoints and in the `author` database table.
12+
13+
- Requires database migration, `113ced7d2d29`.
14+
515
<a id='changelog-0.16.0'></a>
616

717
## 0.16.0 (2025-07-11)

alembic/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
First, the existing database schema should be reflected in the [schema_dump.sql](schema_dump.sql) file. Specifically, the `COPY public.alembic_version` line should have the ID of the latest existing migration. If the schema dump is not up-to-date, check out a version of Ook that has the schema for the last migration and run the following command from the repo's root directory:
88

99
```bash
10-
nox -s db-dump-schema
10+
nox -s dump-db-schema
1111
```
1212

1313
This updates [schema_dump.sql](schema_dump.sql).

alembic/schema_dump.sql

Lines changed: 1 addition & 88 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
"""Drop collaboration table.
2+
3+
Revision ID: 113ced7d2d29
4+
Revises: 176f421b2597
5+
Create Date: 2025-07-15 17:30:15.521566+00:00
6+
"""
7+
8+
from collections.abc import Sequence
9+
10+
import sqlalchemy as sa
11+
from sqlalchemy.dialects import postgresql
12+
13+
from alembic import op
14+
15+
# revision identifiers, used by Alembic.
16+
revision: str = "113ced7d2d29"
17+
down_revision: str | None = "176f421b2597"
18+
branch_labels: str | Sequence[str] | None = None
19+
depends_on: str | Sequence[str] | None = None
20+
21+
22+
def upgrade() -> None:
23+
op.drop_index(
24+
op.f("ix_collaboration_internal_id"), table_name="collaboration"
25+
)
26+
op.drop_index(op.f("ix_collaboration_name"), table_name="collaboration")
27+
op.drop_table("collaboration")
28+
29+
30+
def downgrade() -> None:
31+
op.create_table(
32+
"collaboration",
33+
sa.Column("id", sa.BIGINT(), autoincrement=True, nullable=False),
34+
sa.Column(
35+
"internal_id", sa.TEXT(), autoincrement=False, nullable=False
36+
),
37+
sa.Column("name", sa.TEXT(), autoincrement=False, nullable=False),
38+
sa.Column(
39+
"date_updated",
40+
postgresql.TIMESTAMP(timezone=True),
41+
autoincrement=False,
42+
nullable=False,
43+
),
44+
sa.PrimaryKeyConstraint("id", name=op.f("collaboration_pkey")),
45+
sa.UniqueConstraint(
46+
"internal_id",
47+
"name",
48+
name=op.f("uq_collaboration_internal_id_name"),
49+
postgresql_include=[],
50+
postgresql_nulls_not_distinct=False,
51+
),
52+
)
53+
op.create_index(
54+
op.f("ix_collaboration_name"), "collaboration", ["name"], unique=False
55+
)
56+
op.create_index(
57+
op.f("ix_collaboration_internal_id"),
58+
"collaboration",
59+
["internal_id"],
60+
unique=True,
61+
)

src/ook/dbschema/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
"""SQLAlchemy database schema."""
22

3-
from .authors import (
4-
SqlAffiliation,
5-
SqlAuthor,
6-
SqlAuthorAffiliation,
7-
SqlCollaboration,
8-
)
3+
from .authors import SqlAffiliation, SqlAuthor, SqlAuthorAffiliation
94
from .base import Base
105
from .glossary import SqlTerm, term_relationships
116
from .links import SqlLink, SqlSdmColumnLink, SqlSdmSchemaLink, SqlSdmTableLink
@@ -16,7 +11,6 @@
1611
"SqlAffiliation",
1712
"SqlAuthor",
1813
"SqlAuthorAffiliation",
19-
"SqlCollaboration",
2014
"SqlLink",
2115
"SqlSdmColumn",
2216
"SqlSdmColumnLink",

src/ook/dbschema/authors.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"SqlAffiliation",
2222
"SqlAuthor",
2323
"SqlAuthorAffiliation",
24-
"SqlCollaboration",
2524
]
2625

2726

@@ -86,44 +85,6 @@ class SqlAuthor(Base):
8685
"""The date this record was last updated."""
8786

8887

89-
class SqlCollaboration(Base):
90-
"""A SQLAlchemy model for collaborations."""
91-
92-
__tablename__ = "collaboration"
93-
94-
__table_args__ = (
95-
UniqueConstraint(
96-
"internal_id", "name", name="uq_collaboration_internal_id_name"
97-
),
98-
)
99-
100-
id: Mapped[int] = mapped_column(
101-
BigInteger, primary_key=True, autoincrement=True
102-
)
103-
"""The primary key."""
104-
105-
internal_id: Mapped[str] = mapped_column(
106-
UnicodeText, nullable=False, index=True, unique=True
107-
)
108-
"""The internal ID of the collaboration.
109-
110-
This is the key for the collaboration in lsst-texmf's authordb.yaml file.
111-
"""
112-
113-
name: Mapped[str | None] = mapped_column(
114-
UnicodeText, nullable=False, index=True
115-
)
116-
"""The name of the collaboration (unicode)."""
117-
118-
date_updated: Mapped[datetime] = mapped_column(
119-
DateTime(timezone=True), nullable=False
120-
)
121-
"""The date this record was last updated."""
122-
123-
# TODO(jonathansick): consider adding an ordered many-to-many
124-
# relationship to authors, but this is not needed for now.
125-
126-
12788
class SqlAffiliation(Base):
12889
"""A SQLAlchemy model for affiliations."""
12990

src/ook/domain/authors.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from pydantic import BaseModel, Field
66

7-
__all__ = ["Address", "Affiliation", "Author", "Collaboration"]
7+
__all__ = ["Address", "Affiliation", "Author"]
88

99

1010
class Address(BaseModel):
@@ -59,16 +59,6 @@ class Affiliation(BaseModel):
5959
)
6060

6161

62-
class Collaboration(BaseModel):
63-
"""A collaboration."""
64-
65-
name: str = Field(description="Name of the collaboration.")
66-
67-
internal_id: str = Field(
68-
description="Internal ID of the collaboration.",
69-
)
70-
71-
7262
class Author(BaseModel):
7363
"""An author."""
7464

src/ook/services/ingest/lssttexmf.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,6 @@ async def _ingest_authordb(
127127
await self._author_store.upsert_authors(
128128
list(authors.values()), delete_stale_records=delete_stale_records
129129
)
130-
await self._author_store.upsert_collaborations(
131-
collaborations=list(
132-
author_db_data.collaborations_to_domain().values()
133-
),
134-
delete_stale_records=delete_stale_records,
135-
)
136130

137131
async def _ingest_glossary(self, repo: LsstTexmfGitHubRepo) -> None:
138132
"""Ingest the glossarydefs.csv file."""

0 commit comments

Comments
 (0)