You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
synctv/migrations/20260426032_create_settings...

34 lines
1.0 KiB
MySQL

8 months ago
CREATE TABLE IF NOT EXISTS settings (
key VARCHAR(200) PRIMARY KEY,
Refactor: Rename streaming → livestream throughout codebase (#7) * Initial plan * Add comprehensive testing plan and start test infrastructure Co-authored-by: zijiren233 <84728412+zijiren233@users.noreply.github.com> * Fix test failures: update LiveQuery tests to use snake_case and remove unused imports Co-authored-by: zijiren233 <84728412+zijiren233@users.noreply.github.com> * Fix database migrations: fix UNSIGNED keyword, duplicate timestamps, reserved keywords, and type mismatches Co-authored-by: zijiren233 <84728412+zijiren233@users.noreply.github.com> * Add comprehensive test results summary documenting all fixes and test coverage Co-authored-by: zijiren233 <84728412+zijiren233@users.noreply.github.com> * Add comprehensive e2e integration tests covering auth, permissions, streaming, and error handling Co-authored-by: zijiren233 <84728412+zijiren233@users.noreply.github.com> * Change JWT from RS256 (RSA keys) to HS256 (secret) Co-authored-by: zijiren233 <84728412+zijiren233@users.noreply.github.com> * Add JWT migration documentation Co-authored-by: zijiren233 <84728412+zijiren233@users.noreply.github.com> * Fix config loading, OAuth2 registry, settings column, and HLS routes Co-authored-by: zijiren233 <84728412+zijiren233@users.noreply.github.com> * Fix UserRole/UserStatus database type encoding/decoding Co-authored-by: zijiren233 <84728412+zijiren233@users.noreply.github.com> * Add comprehensive API test suite with results documentation - Comprehensive test script covering 13 API categories (24+ endpoints) - Tests health, auth, user, room, media, playback, provider, notification, OAuth2 endpoints - 15/24 tests passing (62.5% success rate) - Detailed documentation of test results and known issues - Multi-user testing with JWT authentication - Automated test script with color-coded output Co-authored-by: zijiren233 <84728412+zijiren233@users.noreply.github.com> * Fix API endpoints: notifications, room list queries, and proto serialization - Fix notification read-all endpoint to accept optional JSON body - Fix RoomStatus database queries to use numeric values instead of strings - Fix room list endpoint proto serialization (remove json!() wrapper) - Add comprehensive API test suite and results documentation - 10/17 endpoints now passing (58% success rate) Co-authored-by: zijiren233 <84728412+zijiren233@users.noreply.github.com> * Fix proto generation: regenerate Room struct with missing fields Root cause: Room proto definition in client.proto had description (field 8) and updated_at (field 9) but the generated Rust code was stale and only had fields up to member_count (field 7). This caused room creation to fail with "invalid type: null, expected u64" error when room_to_proto_basic() tried to set non-existent fields. Solution: Regenerate proto Rust code by rebuilding synctv-proto package with protoc installed. This properly generates the Room struct with all 9 fields. Co-authored-by: zijiren233 <84728412+zijiren233@users.noreply.github.com> * Fix room creation: proto generation, RoomSettings deserialization, and status encoding Co-authored-by: zijiren233 <84728412+zijiren233@users.noreply.github.com> * Fix room status encoding and add nanoid PostgreSQL function - Created nanoid() PostgreSQL function for ID generation in triggers - Fixed RoomRepository to use i16 encoding/decoding for status column - Added i16_to_status() helper method - Updated row_to_room(), update(), and update_status() to use i16 instead of string - Fixed create_root_playlist trigger to use NEW.created_by (not creator_id) Co-authored-by: zijiren233 <84728412+zijiren233@users.noreply.github.com> * Fix room_member repository: correct column references and status types - Fixed SQL query to use rooms.id instead of incorrect rooms.room_id - Fixed room status check to use i16 (1=Active) instead of string comparison - Improved error handling for invalid room status Co-authored-by: zijiren233 <84728412+zijiren233@users.noreply.github.com> * Fix RoomRole and MemberStatus encoding in room_member repository - Removed .to_string() calls on role and status bindings - Allow sqlx custom encoders to handle i16 conversion - Fixes "column role is of type smallint but expression is of type text" error - Applied to add(), add_with_transaction(), update_role(), and update_status() methods Co-authored-by: zijiren233 <84728412+zijiren233@users.noreply.github.com> * Fix RoomRole and MemberStatus encoding in room_member repository Co-authored-by: zijiren233 <84728412+zijiren233@users.noreply.github.com> * Fix missing admin_*_permissions columns in SELECT queries Fixed 4 SELECT queries in room_member.rs that were missing admin_added_permissions and admin_removed_permissions columns: - get() method (line 203) - get_any() method (line 225) - list_by_room() method (line 247) - list_by_room_with_online() method (line 273) This was causing "no column found for name: admin_added_permissions" errors when permission checks tried to decode the RoomMember from query results. Co-authored-by: zijiren233 <84728412+zijiren233@users.noreply.github.com> * Fix database trigger and missing columns in room member queries Co-authored-by: zijiren233 <84728412+zijiren233@users.noreply.github.com> * Delete generated markdown files Co-authored-by: zijiren233 <84728412+zijiren233@users.noreply.github.com> * Remove SQL nanoid function and move root playlist creation to Rust Co-authored-by: zijiren233 <84728412+zijiren233@users.noreply.github.com> * Delete nanoid SQL files directly instead of creating drop migration Co-authored-by: zijiren233 <84728412+zijiren233@users.noreply.github.com> * Refactor: rename streaming → livestream throughout codebase - Renamed synctv-stream directory to synctv-livestream - Renamed src/streaming to src/livestream - Updated config files: streaming → livestream - Updated all code references throughout - Updated Cargo.toml workspace config - Updated test files Co-authored-by: zijiren233 <84728412+zijiren233@users.noreply.github.com> * Fix remaining streaming → livestream references - Fixed module path in rtmp.rs - Fixed imports in api/livestream.rs - Fixed imports in protocols/hls/server.rs - Build now passes successfully Co-authored-by: zijiren233 <84728412+zijiren233@users.noreply.github.com> --------- Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com> Co-authored-by: zijiren233 <84728412+zijiren233@users.noreply.github.com>
8 months ago
group_name VARCHAR(100) NOT NULL,
value TEXT NOT NULL DEFAULT '',
7 months ago
version INTEGER NOT NULL DEFAULT 0,
8 months ago
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
5 months ago
CREATE INDEX IF NOT EXISTS idx_settings_group ON settings(group_name);
8 months ago
CREATE TRIGGER trigger_update_settings_updated_at
5 months ago
BEFORE UPDATE ON settings
FOR EACH ROW
EXECUTE FUNCTION update_updated_at_column();
8 months ago
CREATE OR REPLACE FUNCTION notify_settings_change()
RETURNS TRIGGER AS $$
BEGIN
IF TG_OP = 'INSERT' OR TG_OP = 'UPDATE' THEN
PERFORM pg_notify('settings_changed', NEW.key);
RETURN NEW;
ELSIF TG_OP = 'DELETE' THEN
PERFORM pg_notify('settings_changed', OLD.key);
RETURN OLD;
END IF;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER settings_change_trigger
AFTER INSERT OR UPDATE OR DELETE ON settings
FOR EACH ROW
EXECUTE FUNCTION notify_settings_change();