Skip to content

Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.

release: v2.1.0 - remove Reddit data from the database

spacesdrive453ac0c8048b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index aca461a..1d9cd62 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,19 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
+## [2.1.0] - 2026-11-05
+
+The database part of removing Reddit. What an instance owner must do: deploy 2.0.0 or later first, export any Reddit rows you want to keep (the queries are in `docs/platform-v2/DATABASE_MIGRATION.md`), then run `npm run db:push` and `npm run db:schema`. Until then the app keeps working and simply ignores the Reddit rows.
+
+### Removed
+
+- Reddit accounts, including the session cookies and encrypted passwords they stored, and tracked Reddit posts are deleted from the database (#145)
+- `tracked_posts.account_id`, its foreign key and its check, which only Reddit items used (#145)
+
+### Changed
+
+- Accounts allow only YouTube and Instagram, tracked items only YouTube videos, and the one-account-per-user index no longer has a Reddit branch (#145)
+
## [2.0.1] - 2026-11-05
Security fixes from the first full audit (`docs/platform-v2/SECURITY_AUDIT.md`). What an instance owner must do: deploy as usual. Connecting Instagram now returns to the Accounts page, which finishes the connection, so keep the app and the Worker on the same version.
diff --git a/docs/architecture/database/SCHEMA.md b/docs/architecture/database/SCHEMA.md
index 244b6cf..91538d8 100644
--- a/docs/architecture/database/SCHEMA.md
+++ b/docs/architecture/database/SCHEMA.md
@@ -71,12 +71,12 @@ Stores connected YouTube channels and Instagram accounts.
| Constraint | Rule |
|---|---|
-| `accounts_platform_check` | `platform` is `'youtube'` or `'instagram'`, or the value of the platform removed in v2.0.0 (below) |
+| `accounts_platform_check` | `platform` is `'youtube'` or `'instagram'` |
| `accounts_data_check` | `data` is a JSON object |
| `accounts_id_user_id_key` | `unique (id, user_id)`, so posts can reference an account together with its owner |
| `accounts_identity_key` | Unique index on `(user_id, platform, identity)`, where the identity is `data ->> 'channelId'` for YouTube and `data ->> 'igUserId'` for Instagram. Two adds of the same account at the same moment store one row; the other gets the usual 409 |
-The app reads and writes only YouTube and Instagram accounts: `accountRepository` selects rows whose `platform` is `youtube` or `instagram`. The check and the identity index still allow a value from a platform removed in v2.0.0, and rows of that platform may remain in the table, unseen by the app. The cleanup in #145 removes those rows, narrows the check and rebuilds the index (see `docs/platform-v2/DATABASE_MIGRATION.md` and ADR-049 in `DECISIONS.md`).
+`accountRepository` still selects only `youtube` and `instagram` rows, which the check now guarantees. The rows, check value and index branch of the platform removed in v2.0.0 were deleted by the cleanup migrations of #145 (`docs/platform-v2/DATABASE_MIGRATION.md`, ADR-049 in `DECISIONS.md`).
### `data` jsonb shape for YouTube accounts
@@ -219,31 +219,26 @@ A claim is one UPDATE that sets `status = 'publishing'`, `claimed_at = now()` an
## Table: `tracked_posts`
-Stores the YouTube videos the user wants to monitor. The app tracks YouTube videos only: `trackedPostRepository` reads rows whose `content_type` is `youtube`, writes `content_type: 'youtube'` on every insert and never writes `account_id`.
+Stores the YouTube videos the user wants to monitor. `trackedPostRepository` writes `content_type: 'youtube'` on every insert and reads only `youtube` rows, which the check now guarantees.
| Column | Type | Nullable | Description |
|---|---|---|---|
| `id` | text | NOT NULL | PK. A UUID from `newRowId()`; older rows keep their earlier ids |
| `user_id` | uuid | NOT NULL | FK -> `auth.users.id` ON DELETE CASCADE |
-| `account_id` | text | NULL | With `user_id`, FK -> `accounts (id, user_id)` ON DELETE SET NULL (`account_id`). No longer written; the cleanup in #145 drops it |
| `url` | text | NOT NULL | Full URL of the YouTube video |
| `label` | text | NOT NULL DEFAULT '' | User-defined name for the item |
| `category` | text | NOT NULL DEFAULT '' | User-defined grouping label |
-| `content_type` | text | NOT NULL DEFAULT (see below) | `'youtube'`. The app always sets it, so the default, the removed platform's value, is never used |
+| `content_type` | text | NOT NULL DEFAULT 'youtube' | `'youtube'`; kept as a column so another kind of tracked item can be added with one check change |
| `created_at` | timestamptz | NOT NULL DEFAULT now() | When the user added the item |
| `updated_at` | timestamptz | NOT NULL DEFAULT now() | Set by the trigger on every update; the code no longer sets it |
| `data` | jsonb | NULL | Cached data fetched from the platform API, stored in the same insert that creates the row (see below) |
| Constraint | Rule |
|---|---|
-| `tracked_posts_content_type_check` | `content_type` is `'youtube'`, or the value of the platform removed in v2.0.0 |
-| `tracked_posts_account_check` | Only items of the removed platform may have an account, so a YouTube item's `account_id` is null |
+| `tracked_posts_content_type_check` | `content_type` is `'youtube'` |
| `tracked_posts_data_check` | `data` is null or a JSON object |
-| `tracked_posts_account_fkey` | `(account_id, user_id)` -> `accounts (id, user_id)` ON DELETE SET NULL (`account_id`) |
-Removing an account keeps its tracked items and clears only their `account_id`. The column list on SET NULL needs Postgres 15 or later; a plain SET NULL would try to clear `user_id` too.
-
-The default, the two checks and `account_id` are left from the platform removed in v2.0.0, and its tracked items may remain in the table, unseen by the app. The cleanup in #145 deletes those rows, makes `'youtube'` the only allowed value and the default, and drops `tracked_posts_account_check`, `tracked_posts_account_fkey` and `account_id` (see `docs/platform-v2/DATABASE_MIGRATION.md` and ADR-049 in `DECISIONS.md`).
+The cleanup migrations of #145 deleted the tracked items of the platform removed in v2.0.0 and dropped `account_id` with its foreign key and check, which only that platform used (`docs/platform-v2/DATABASE_MIGRATION.md`, ADR-049 in `DECISIONS.md`).
### `data` jsonb shape for YouTube items
diff --git a/docs/platform-v2/DATABASE_MIGRATION.md b/docs/platform-v2/DATABASE_MIGRATION.md
index 46754fc..279b945 100644
--- a/docs/platform-v2/DATABASE_MIGRATION.md
+++ b/docs/platform-v2/DATABASE_MIGRATION.md
@@ -45,10 +45,27 @@ Each runs in its own transaction (the Supabase CLI wraps every file), so a file
| File (verb first) | What it does | Rollback |
|---|---|---|
-| `alter_tracked_posts_youtube_only` | Deletes tracked posts with `content_type = 'reddit'`, drops `tracked_posts_account_check`, replaces `tracked_posts_content_type_check` with `content_type = 'youtube'`, sets the default to `'youtube'` | Restores both checks as they were and the `'reddit'` default; the rows come back from the backup |
-| `drop_tracked_posts_account_id` | Drops `tracked_posts_account_fkey` and the `account_id` column | Adds the nullable column and the foreign key back (`on delete set null (account_id)`) |
-| `alter_accounts_without_reddit` | Deletes accounts with `platform = 'reddit'` and replaces `accounts_platform_check` with `('youtube', 'instagram')` | Restores the three-platform check; the rows come back from the backup |
-| `replace_accounts_identity_index` | Drops `accounts_identity_key` and creates it again without the Reddit branch | Creates the index with the Reddit branch again |
+| `20261104222452_alter_tracked_posts_youtube_only` | Deletes tracked posts with `content_type = 'reddit'`, drops `tracked_posts_account_check`, replaces `tracked_posts_content_type_check` with `content_type = 'youtube'`, sets the default to `'youtube'` | Restores both checks as they were and the `'reddit'` default; the rows come back from the backup |
+| `20261104222455_drop_tracked_posts_account_id` | Drops `tracked_posts_account_fkey` and the `account_id` column | Adds the nullable column and the foreign key back (`on delete set null (account_id)`) |
+| `20261104222458_alter_accounts_without_reddit` | Deletes accounts with `platform = 'reddit'` and replaces `accounts_platform_check` with `('youtube', 'instagram')` | Restores the three-platform check; the rows come back from the backup |
+| `20261104222501_replace_accounts_identity_index` | Drops `accounts_identity_key` and creates it again without the Reddit branch | Creates the index with the Reddit branch again |
+
+The files are in `supabase/migrations/` with their rollbacks in `supabase/rollbacks/`, and `supabase/schemas/` already shows the result.
+
+### Queries for the review (read only, in the Supabase SQL editor)
+
+```sql
+-- how many rows the cleanup deletes
+select 'accounts' as rows, count(*) from public.accounts where platform = 'reddit'
+union all
+select 'tracked_posts', count(*) from public.tracked_posts where content_type = 'reddit'
+union all
+select 'tracked_posts with an account', count(*) from public.tracked_posts where account_id is not null;
+
+-- the backup: run each, then Download, CSV, and keep the files outside the repository
+select * from public.accounts where platform = 'reddit';
+select * from public.tracked_posts where content_type = 'reddit' or account_id is not null;
+```
A rollback restores the schema; Reddit rows are restored by loading the backup CSV into the tables with the Supabase table editor or `\copy`, after the rollback has run.
diff --git a/package-lock.json b/package-lock.json
index b0c8d4d..77185a1 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "twiligent",
- "version": "2.0.1",
+ "version": "2.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "twiligent",
- "version": "2.0.1",
+ "version": "2.1.0",
"workspaces": [
"backend",
"frontend",
diff --git a/package.json b/package.json
index e8909d7..9bca80e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "twiligent",
- "version": "2.0.1",
+ "version": "2.1.0",
"private": true,
"description": "Self-hosted social media analytics and publishing dashboard",
"workspaces": [