Skip to content

Commit

Permalink
Revert "Add html column to entry"
Browse files Browse the repository at this point in the history
This reverts commit 9949f6e.
  • Loading branch information
LukeLR committed Aug 6, 2023
1 parent 9949f6e commit 01a4c89
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
7 changes: 3 additions & 4 deletions rss/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ class Entry:
title: str
summary: str
link: str
html: str

@classmethod
def from_row(cls, row: Record | None) -> Entry | None:
Expand Down Expand Up @@ -144,7 +143,7 @@ async def get_feeds_by_room(self, room_id: RoomID) -> list[tuple[Feed, UserID]]:
return [(Feed.from_row(row), row["user_id"]) for row in rows]

async def get_entries(self, feed_id: int) -> list[Entry]:
q = "SELECT feed_id, id, date, title, summary, link, html FROM entry WHERE feed_id = $1"
q = "SELECT feed_id, id, date, title, summary, link FROM entry WHERE feed_id = $1"
return [Entry.from_row(row) for row in await self.db.fetch(q, feed_id)]

async def add_entries(self, entries: list[Entry], override_feed_id: int | None = None) -> None:
Expand All @@ -154,13 +153,13 @@ async def add_entries(self, entries: list[Entry], override_feed_id: int | None =
for entry in entries:
entry.feed_id = override_feed_id
records = [attr.astuple(entry) for entry in entries]
columns = ("feed_id", "id", "date", "title", "summary", "link", "html")
columns = ("feed_id", "id", "date", "title", "summary", "link")
async with self.db.acquire() as conn:
if self.db.scheme == Scheme.POSTGRES:
await conn.copy_records_to_table("entry", records=records, columns=columns)
else:
q = (
"INSERT INTO entry (feed_id, id, date, title, summary, link, html) "
"INSERT INTO entry (feed_id, id, date, title, summary, link) "
"VALUES ($1, $2, $3, $4, $5, $6)"
)
await conn.executemany(q, records)
Expand Down
6 changes: 1 addition & 5 deletions rss/migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

upgrade_table = UpgradeTable()


@upgrade_table.register(description="Latest revision", upgrades_to=3)
async def upgrade_latest(conn: Connection, scheme: Scheme) -> None:
gen = "GENERATED ALWAYS AS IDENTITY" if scheme != Scheme.SQLITE else ""
Expand Down Expand Up @@ -71,8 +72,3 @@ async def upgrade_v2(conn: Connection) -> None:
async def upgrade_v3(conn: Connection) -> None:
await conn.execute("ALTER TABLE feed ADD COLUMN next_retry BIGINT DEFAULT 0")
await conn.execute("ALTER TABLE feed ADD COLUMN error_count BIGINT DEFAULT 0")


@upgrade_table.register(description="Add html field to entry")
async def upgrade_v4(conn: Connection) -> None:
await conn.execute("ALTER TABLE entry ADD COLUMN html TEXT")

0 comments on commit 01a4c89

Please sign in to comment.