Files
fusion/docs/old-database-schema.md
T
Yuan ad25dde50f refactor (#210)
* init refactor plan

* remove old files

* api design

* implement store layer

* implement api

* Add comments for store package

* init frontend

* implement pull service

* use slog

* two column layout

* new design

* fix env var

* fix

* stabilize store tests and query ordering

* remove settings.local.json and update .gitignore to exclude .claude

* improve layout and styling in sidebar and settings dialog

* add group management modal

* add feed management

* add OPML import and export

* use favicon

* fix article list

* fix

* fix ui

* search debounce

* fix ui

* store states in url

* fix: resolve nested button hydration error in ArticleItem

* edit feed

* filter items by group

* fix ui

* fade unread count

* add confirmation dialog for feed deletion and bold key names in confirmations

* fix search

* add optional OIDC authentication support

Allow self-hosted users to integrate with SSO providers (Authelia, Keycloak, etc.)
via OIDC. Enabled by setting FUSION_OIDC_ISSUER and related env vars. Uses PKCE S256
for security. When disabled, behavior is unchanged — login page shows password only.

* add article content processing with link, image, and tracking pixel handling

* replace goreleaser with shell script for cross-platform builds

Remove .goreleaser.yaml and add a `release` command to scripts.sh that
builds 6 platform combos (linux/darwin/windows × amd64/arm64), creates
zip archives with LICENSE/README, and generates sha256 checksums.

Update release workflow to use scripts.sh + gh CLI instead of
goreleaser-action. All build paths updated for backend/ subdirectory.

* implement feed discovery with feedfinder and feed selection

Replace placeholder feed validation with real RSS/Atom discovery so users can pick the correct feed URL before subscribing.

* standardize icon button sizes and improve responsive layout

* auto-fill empty site_url and keep OPML htmlUrl metadata

* add feed management page

* fix about panel

* responsive optimization

* fix search dialog result display and article drawer blank issue

- Add unique value props to CommandItems to prevent cmdk deduplication
- Use getFeedById from store instead of searching within search results
- Fetch article from API when not found in store (e.g. opened from search)

* improve AGENTS.md

* use tanstack-query

* harden auth config and optimize feed pulling

* optimize frontend route loading and lint compliance

Split heavy pages into lazy-loaded route modules to reduce initial bundle size and keep startup responsive. Also fix lint blockers in search/login flows and align ESLint rules with shadcn ui exports.

* harden feed networking and improve store query performance

* expand backend tests and unify test helpers

* fix unstable fallback GUID generation for feed items

* update docs

* simplify command responses with 204 and 202 statuses

* enforce foreign keys in initial sqlite schema

* use upstream static icons for frontend branding

* refactor ci

* add gray fallback for missing feed favicons

* highlight AI-free value in README

* enhance frontend PWA install and update flow

Expose browser install prompts in settings and add service worker update handoff so users can install Fusion and apply new versions without manual cache clearing.

* add robust legacy sqlite migration path

Automatically detect pre-migration schemas and rebuild them into the current schema so upgrades preserve user data safely and idempotently.

* embed frontend build artifacts into backend binary

* fix login flow for empty-password setups

* fix gin server mode to release

* fix

* add visibility logs for database migrations

* fix starred button background in dark mode

* align gin HTTP logging with slog output

* optimize user guidance

* refactor reader routes to path-based state

* update screenshots
2026-02-12 00:29:58 +08:00

3.3 KiB

Legacy Database Schema (Preserved)

This document preserves the legacy schema snapshot for migration development and validation. SQL DDL is the single source of truth for table/column definitions.

Full DDL (Authoritative)

CREATE TABLE `groups` (
  `id` integer PRIMARY KEY AUTOINCREMENT,
  `created_at` datetime,
  `updated_at` datetime,
  `deleted_at` integer,
  `name` text NOT NULL
);

CREATE TABLE sqlite_sequence(name,seq);

CREATE UNIQUE INDEX `idx_name` ON `groups`(`deleted_at`,`name`);

CREATE TABLE `feeds` (
  `id` integer PRIMARY KEY AUTOINCREMENT,
  `created_at` datetime,
  `updated_at` datetime,
  `deleted_at` integer,
  `name` text NOT NULL,
  `link` text NOT NULL,
  `last_build` datetime,
  `failure` text DEFAULT "",
  `group_id` integer,
  `suspended` numeric DEFAULT false,
  `req_proxy` text,
  `consecutive_failures` integer DEFAULT 0,
  CONSTRAINT `fk_feeds_group` FOREIGN KEY (`group_id`) REFERENCES `groups`(`id`)
);

CREATE TABLE `items` (
  `id` integer PRIMARY KEY AUTOINCREMENT,
  `created_at` datetime,
  `updated_at` datetime,
  `deleted_at` integer,
  `title` text NOT NULL,
  `guid` text,
  `link` text,
  `content` text,
  `pub_date` datetime,
  `unread` numeric DEFAULT true,
  `feed_id` integer,
  `bookmark` numeric DEFAULT false,
  CONSTRAINT `fk_items_feed` FOREIGN KEY (`feed_id`) REFERENCES `feeds`(`id`)
);

CREATE INDEX `idx_items_feed_id` ON `items`(`feed_id`);
CREATE INDEX `idx_items_title` ON `items`(`title`);
CREATE INDEX `idx_items_unread` ON `items`(`unread`);
CREATE INDEX `idx_items_bookmark` ON `items`(`bookmark`);

CREATE UNIQUE INDEX `idx_guid` ON `items`(`deleted_at`,`guid`,`feed_id`);
CREATE UNIQUE INDEX `idx_link` ON `feeds`(`deleted_at`,`link`);

Business Logic Notes

1) Entity relationships

  • groups -> feeds -> items is a two-level one-to-many chain.
  • feeds.group_id links each feed to a group.
  • items.feed_id links each item to a feed.
  • Legacy schema declares foreign keys (fk_feeds_group, fk_items_feed).

2) Soft-delete model

  • All business tables use deleted_at (Unix timestamp) for logical delete.
  • Deletes update deleted_at; rows are not physically removed.
  • Unique indexes include deleted_at, so deleted historical rows can coexist with new active rows.

3) Deduplication and uniqueness semantics

  • Group name uniqueness: idx_name(deleted_at, name).
  • Feed link uniqueness: idx_link(deleted_at, link).
  • Item deduplication key: idx_guid(deleted_at, guid, feed_id).
  • SQLite caveat: NULL != NULL in unique indexes, so multiple rows with guid=NULL are allowed (must be preserved in migrations).

4) Feed pull status fields (feeds)

  • last_build: last content update time.
  • failure + consecutive_failures: latest error and failure streak.
  • suspended: pull disabled flag.
  • req_proxy: per-feed proxy setting.

5) Reading state fields (items)

  • unread: unread flag (default true).
  • bookmark: bookmark flag (default false).
  • Both are indexed for high-frequency filtering.

6) Application-level semantics

  • App bootstrap ensures default group exists: id=1, name="Default".
  • unread_count is a virtual field in app models and is not persisted.

Legacy Migration History

After v0.8.7

  • Added unique constraint for feed links via idx_link.
  • Migration removed duplicate feeds and kept the row with the smallest id.