-- -- PostgreSQL database dump -- -- Dumped from database version 16.11 (Debian 16.11-1.pgdg13+1) -- Dumped by pg_dump version 16.8 SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SELECT pg_catalog.set_config('search_path', '', false); SET check_function_bodies = false; SET xmloption = content; SET client_min_messages = warning; SET row_security = off; -- -- Name: pgcrypto; Type: EXTENSION; Schema: -; Owner: - -- CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public; -- -- Name: EXTENSION pgcrypto; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION pgcrypto IS 'cryptographic functions'; -- -- Name: uuid-ossp; Type: EXTENSION; Schema: -; Owner: - -- CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public; -- -- Name: EXTENSION "uuid-ossp"; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION "uuid-ossp" IS 'generate universally unique identifiers (UUIDs)'; -- -- Name: playlist_permission; Type: TYPE; Schema: public; Owner: postgres -- CREATE TYPE public.playlist_permission AS ENUM ( 'read', 'write', 'admin' ); ALTER TYPE public.playlist_permission OWNER TO postgres; SET default_tablespace = ''; SET default_table_access_method = heap; -- -- Name: admin_settings; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.admin_settings ( id uuid DEFAULT gen_random_uuid() NOT NULL, key character varying(255) NOT NULL, value text, type character varying(50), description text, category character varying(50), is_public boolean DEFAULT false, updated_by uuid, updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP ); ALTER TABLE public.admin_settings OWNER TO postgres; -- -- Name: bitrate_adaptation_logs; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.bitrate_adaptation_logs ( id bigint NOT NULL, old_bitrate integer NOT NULL, new_bitrate integer NOT NULL, reason character varying(50) NOT NULL, network_bandwidth integer, created_at timestamp without time zone DEFAULT now() NOT NULL, track_id uuid NOT NULL, user_id uuid NOT NULL ); ALTER TABLE public.bitrate_adaptation_logs OWNER TO postgres; -- -- Name: bitrate_adaptation_logs_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres -- CREATE SEQUENCE public.bitrate_adaptation_logs_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER SEQUENCE public.bitrate_adaptation_logs_id_seq OWNER TO postgres; -- -- Name: bitrate_adaptation_logs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres -- ALTER SEQUENCE public.bitrate_adaptation_logs_id_seq OWNED BY public.bitrate_adaptation_logs.id; -- -- Name: email_verification_tokens; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.email_verification_tokens ( id bigint NOT NULL, token character varying(255) NOT NULL, expires_at timestamp without time zone NOT NULL, used boolean DEFAULT false NOT NULL, created_at timestamp without time zone DEFAULT now() NOT NULL, user_id uuid NOT NULL ); ALTER TABLE public.email_verification_tokens OWNER TO postgres; -- -- Name: email_verification_tokens_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres -- CREATE SEQUENCE public.email_verification_tokens_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER SEQUENCE public.email_verification_tokens_id_seq OWNER TO postgres; -- -- Name: email_verification_tokens_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres -- ALTER SEQUENCE public.email_verification_tokens_id_seq OWNED BY public.email_verification_tokens.id; -- -- Name: federated_identities; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.federated_identities ( id uuid DEFAULT gen_random_uuid() NOT NULL, user_id uuid NOT NULL, provider text NOT NULL, provider_id text NOT NULL, email text, display_name text, avatar_url text, access_token text, refresh_token text, expires_at timestamp with time zone, created_at timestamp with time zone DEFAULT now(), updated_at timestamp with time zone DEFAULT now() ); ALTER TABLE public.federated_identities OWNER TO postgres; -- -- Name: hls_streams; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.hls_streams ( id bigint NOT NULL, playlist_url character varying(500) NOT NULL, segments_count integer DEFAULT 0 NOT NULL, bitrates jsonb DEFAULT '[]'::jsonb NOT NULL, status character varying(20) DEFAULT 'pending'::character varying NOT NULL, created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, track_id uuid NOT NULL ); ALTER TABLE public.hls_streams OWNER TO postgres; -- -- Name: hls_streams_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres -- CREATE SEQUENCE public.hls_streams_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER SEQUENCE public.hls_streams_id_seq OWNER TO postgres; -- -- Name: hls_streams_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres -- ALTER SEQUENCE public.hls_streams_id_seq OWNED BY public.hls_streams.id; -- -- Name: hls_transcode_queue; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.hls_transcode_queue ( id bigint NOT NULL, priority integer DEFAULT 5 NOT NULL, status character varying(20) DEFAULT 'pending'::character varying NOT NULL, retry_count integer DEFAULT 0 NOT NULL, max_retries integer DEFAULT 3 NOT NULL, error_message text, created_at timestamp without time zone DEFAULT now() NOT NULL, started_at timestamp without time zone, completed_at timestamp without time zone, track_id uuid NOT NULL ); ALTER TABLE public.hls_transcode_queue OWNER TO postgres; -- -- Name: hls_transcode_queue_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres -- CREATE SEQUENCE public.hls_transcode_queue_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER SEQUENCE public.hls_transcode_queue_id_seq OWNER TO postgres; -- -- Name: hls_transcode_queue_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres -- ALTER SEQUENCE public.hls_transcode_queue_id_seq OWNED BY public.hls_transcode_queue.id; -- -- Name: password_reset_tokens; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.password_reset_tokens ( id bigint NOT NULL, token character varying(255) NOT NULL, expires_at timestamp without time zone NOT NULL, used boolean DEFAULT false NOT NULL, created_at timestamp without time zone DEFAULT now() NOT NULL, user_id uuid NOT NULL ); ALTER TABLE public.password_reset_tokens OWNER TO postgres; -- -- Name: password_reset_tokens_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres -- CREATE SEQUENCE public.password_reset_tokens_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER SEQUENCE public.password_reset_tokens_id_seq OWNER TO postgres; -- -- Name: password_reset_tokens_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres -- ALTER SEQUENCE public.password_reset_tokens_id_seq OWNED BY public.password_reset_tokens.id; -- -- Name: permissions; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.permissions ( name character varying(100) NOT NULL, resource character varying(50) NOT NULL, action character varying(50) NOT NULL, description text, created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP, id uuid DEFAULT gen_random_uuid() NOT NULL ); ALTER TABLE public.permissions OWNER TO postgres; -- -- Name: TABLE permissions; Type: COMMENT; Schema: public; Owner: postgres -- COMMENT ON TABLE public.permissions IS 'System permissions for RBAC (migrated to UUID)'; -- -- Name: playback_analytics; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.playback_analytics ( id bigint NOT NULL, play_time integer DEFAULT 0 NOT NULL, pause_count integer DEFAULT 0 NOT NULL, seek_count integer DEFAULT 0 NOT NULL, completion_rate numeric(5,2) DEFAULT 0 NOT NULL, started_at timestamp without time zone NOT NULL, ended_at timestamp without time zone, created_at timestamp without time zone DEFAULT now() NOT NULL, track_id uuid NOT NULL, user_id uuid NOT NULL ); ALTER TABLE public.playback_analytics OWNER TO postgres; -- -- Name: playback_analytics_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres -- CREATE SEQUENCE public.playback_analytics_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER SEQUENCE public.playback_analytics_id_seq OWNER TO postgres; -- -- Name: playback_analytics_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres -- ALTER SEQUENCE public.playback_analytics_id_seq OWNED BY public.playback_analytics.id; -- -- Name: playlist_collaborators; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.playlist_collaborators ( id bigint NOT NULL, permission character varying(20) DEFAULT 'read'::character varying NOT NULL, created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, deleted_at timestamp without time zone, user_id uuid NOT NULL, playlist_id uuid NOT NULL, CONSTRAINT chk_playlist_collaborators_permission CHECK (((permission)::text = ANY ((ARRAY['read'::character varying, 'write'::character varying, 'admin'::character varying])::text[]))) ); ALTER TABLE public.playlist_collaborators OWNER TO postgres; -- -- Name: TABLE playlist_collaborators; Type: COMMENT; Schema: public; Owner: postgres -- COMMENT ON TABLE public.playlist_collaborators IS 'Table des collaborateurs de playlists avec leurs permissions'; -- -- Name: COLUMN playlist_collaborators.permission; Type: COMMENT; Schema: public; Owner: postgres -- COMMENT ON COLUMN public.playlist_collaborators.permission IS 'Permission du collaborateur: read (lecture), write (écriture), admin (administration)'; -- -- Name: playlist_collaborators_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres -- CREATE SEQUENCE public.playlist_collaborators_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER SEQUENCE public.playlist_collaborators_id_seq OWNER TO postgres; -- -- Name: playlist_collaborators_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres -- ALTER SEQUENCE public.playlist_collaborators_id_seq OWNED BY public.playlist_collaborators.id; -- -- Name: playlist_follows; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.playlist_follows ( id bigint NOT NULL, created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, deleted_at timestamp without time zone, user_id uuid NOT NULL, playlist_id uuid NOT NULL ); ALTER TABLE public.playlist_follows OWNER TO postgres; -- -- Name: TABLE playlist_follows; Type: COMMENT; Schema: public; Owner: postgres -- COMMENT ON TABLE public.playlist_follows IS 'Table des follows de playlists par les utilisateurs'; -- -- Name: playlist_follows_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres -- CREATE SEQUENCE public.playlist_follows_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER SEQUENCE public.playlist_follows_id_seq OWNER TO postgres; -- -- Name: playlist_follows_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres -- ALTER SEQUENCE public.playlist_follows_id_seq OWNED BY public.playlist_follows.id; -- -- Name: playlist_tracks; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.playlist_tracks ( "position" integer NOT NULL, added_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, track_id uuid NOT NULL, playlist_id uuid NOT NULL, id uuid DEFAULT gen_random_uuid() NOT NULL ); ALTER TABLE public.playlist_tracks OWNER TO postgres; -- -- Name: playlists; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.playlists ( title character varying(200) NOT NULL, description text, is_public boolean DEFAULT true, cover_url character varying(500), track_count integer DEFAULT 0, created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, follower_count integer DEFAULT 0, deleted_at timestamp with time zone, user_id uuid NOT NULL, id uuid DEFAULT gen_random_uuid() NOT NULL ); ALTER TABLE public.playlists OWNER TO postgres; -- -- Name: refresh_tokens; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.refresh_tokens ( id bigint NOT NULL, token_hash character varying(255) NOT NULL, expires_at timestamp with time zone NOT NULL, created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP, deleted_at timestamp with time zone, user_id uuid NOT NULL ); ALTER TABLE public.refresh_tokens OWNER TO postgres; -- -- Name: TABLE refresh_tokens; Type: COMMENT; Schema: public; Owner: postgres -- COMMENT ON TABLE public.refresh_tokens IS 'JWT refresh tokens for persistent authentication (T0165)'; -- -- Name: COLUMN refresh_tokens.token_hash; Type: COMMENT; Schema: public; Owner: postgres -- COMMENT ON COLUMN public.refresh_tokens.token_hash IS 'SHA-256 hash of the refresh token'; -- -- Name: COLUMN refresh_tokens.expires_at; Type: COMMENT; Schema: public; Owner: postgres -- COMMENT ON COLUMN public.refresh_tokens.expires_at IS 'Token expiration timestamp'; -- -- Name: refresh_tokens_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres -- CREATE SEQUENCE public.refresh_tokens_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER SEQUENCE public.refresh_tokens_id_seq OWNER TO postgres; -- -- Name: refresh_tokens_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres -- ALTER SEQUENCE public.refresh_tokens_id_seq OWNED BY public.refresh_tokens.id; -- -- Name: role_permissions; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.role_permissions ( role_id uuid NOT NULL, permission_id uuid NOT NULL ); ALTER TABLE public.role_permissions OWNER TO postgres; -- -- Name: TABLE role_permissions; Type: COMMENT; Schema: public; Owner: postgres -- COMMENT ON TABLE public.role_permissions IS 'Role permission mappings (migrated to UUID)'; -- -- Name: roles; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.roles ( name character varying(50) NOT NULL, display_name character varying(100) NOT NULL, description text, is_system boolean DEFAULT false, is_active boolean DEFAULT true, created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP, updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP, id uuid DEFAULT gen_random_uuid() NOT NULL ); ALTER TABLE public.roles OWNER TO postgres; -- -- Name: TABLE roles; Type: COMMENT; Schema: public; Owner: postgres -- COMMENT ON TABLE public.roles IS 'System roles for RBAC (migrated to UUID)'; -- -- Name: rooms; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.rooms ( id bigint NOT NULL, name character varying(255) NOT NULL, description text, room_type character varying(50) DEFAULT 'public'::character varying NOT NULL, is_active boolean DEFAULT true, max_members integer DEFAULT 100, created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP, updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP, deleted_at timestamp with time zone, creator_id uuid NOT NULL, owner_id uuid NOT NULL ); ALTER TABLE public.rooms OWNER TO postgres; -- -- Name: TABLE rooms; Type: COMMENT; Schema: public; Owner: postgres -- COMMENT ON TABLE public.rooms IS 'Chat rooms for real-time messaging'; -- -- Name: COLUMN rooms.room_type; Type: COMMENT; Schema: public; Owner: postgres -- COMMENT ON COLUMN public.rooms.room_type IS 'Type of room: public, private, or direct'; -- -- Name: COLUMN rooms.max_members; Type: COMMENT; Schema: public; Owner: postgres -- COMMENT ON COLUMN public.rooms.max_members IS 'Maximum number of members allowed in the room'; -- -- Name: rooms_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres -- CREATE SEQUENCE public.rooms_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER SEQUENCE public.rooms_id_seq OWNER TO postgres; -- -- Name: rooms_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres -- ALTER SEQUENCE public.rooms_id_seq OWNED BY public.rooms.id; -- -- Name: schema_migrations; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.schema_migrations ( version bigint NOT NULL, dirty boolean NOT NULL ); ALTER TABLE public.schema_migrations OWNER TO postgres; -- -- Name: track_comments; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.track_comments ( id bigint NOT NULL, parent_id bigint, content text NOT NULL, is_edited boolean DEFAULT false, created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP, updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP, deleted_at timestamp without time zone, user_id uuid NOT NULL, track_id uuid NOT NULL ); ALTER TABLE public.track_comments OWNER TO postgres; -- -- Name: track_comments_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres -- CREATE SEQUENCE public.track_comments_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER SEQUENCE public.track_comments_id_seq OWNER TO postgres; -- -- Name: track_comments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres -- ALTER SEQUENCE public.track_comments_id_seq OWNED BY public.track_comments.id; -- -- Name: track_history; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.track_history ( id bigint NOT NULL, action character varying(50) NOT NULL, old_value text, new_value text, created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, track_id uuid NOT NULL, user_id uuid NOT NULL ); ALTER TABLE public.track_history OWNER TO postgres; -- -- Name: track_history_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres -- CREATE SEQUENCE public.track_history_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER SEQUENCE public.track_history_id_seq OWNER TO postgres; -- -- Name: track_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres -- ALTER SEQUENCE public.track_history_id_seq OWNED BY public.track_history.id; -- -- Name: track_likes; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.track_likes ( id bigint NOT NULL, created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP, user_id uuid NOT NULL, track_id uuid NOT NULL ); ALTER TABLE public.track_likes OWNER TO postgres; -- -- Name: track_likes_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres -- CREATE SEQUENCE public.track_likes_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER SEQUENCE public.track_likes_id_seq OWNER TO postgres; -- -- Name: track_likes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres -- ALTER SEQUENCE public.track_likes_id_seq OWNED BY public.track_likes.id; -- -- Name: track_plays; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.track_plays ( id bigint NOT NULL, duration integer NOT NULL, played_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, device character varying(100), ip_address character varying(45), created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, deleted_at timestamp without time zone, track_id uuid NOT NULL, user_id uuid NOT NULL ); ALTER TABLE public.track_plays OWNER TO postgres; -- -- Name: track_plays_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres -- CREATE SEQUENCE public.track_plays_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER SEQUENCE public.track_plays_id_seq OWNER TO postgres; -- -- Name: track_plays_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres -- ALTER SEQUENCE public.track_plays_id_seq OWNED BY public.track_plays.id; -- -- Name: track_shares; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.track_shares ( id bigint NOT NULL, share_token character varying(255) NOT NULL, permissions character varying(50) DEFAULT 'read'::character varying, expires_at timestamp without time zone, access_count bigint DEFAULT 0, created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP, updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP, deleted_at timestamp without time zone, user_id uuid NOT NULL, track_id uuid NOT NULL ); ALTER TABLE public.track_shares OWNER TO postgres; -- -- Name: track_shares_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres -- CREATE SEQUENCE public.track_shares_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER SEQUENCE public.track_shares_id_seq OWNER TO postgres; -- -- Name: track_shares_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres -- ALTER SEQUENCE public.track_shares_id_seq OWNED BY public.track_shares.id; -- -- Name: track_versions; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.track_versions ( id bigint NOT NULL, version_number integer NOT NULL, file_path character varying(500) NOT NULL, file_size bigint NOT NULL, changelog text, created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, deleted_at timestamp without time zone, track_id uuid NOT NULL ); ALTER TABLE public.track_versions OWNER TO postgres; -- -- Name: track_versions_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres -- CREATE SEQUENCE public.track_versions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER SEQUENCE public.track_versions_id_seq OWNER TO postgres; -- -- Name: track_versions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres -- ALTER SEQUENCE public.track_versions_id_seq OWNED BY public.track_versions.id; -- -- Name: tracks; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.tracks ( title character varying(255) NOT NULL, artist character varying(255), album character varying(255), duration integer NOT NULL, genre character varying(100), year integer DEFAULT 0, file_path character varying(500) NOT NULL, file_size bigint NOT NULL, format character varying(10), bitrate integer DEFAULT 0, sample_rate integer DEFAULT 0, waveform_path character varying(500), cover_art_path character varying(500), is_public boolean DEFAULT true, play_count bigint DEFAULT 0, like_count bigint DEFAULT 0, created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP, updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP, deleted_at timestamp without time zone, status character varying(20) DEFAULT 'uploading'::character varying, status_message text, user_id uuid NOT NULL, id uuid DEFAULT gen_random_uuid() NOT NULL ); ALTER TABLE public.tracks OWNER TO postgres; -- -- Name: user_roles; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.user_roles ( assigned_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP, expires_at timestamp without time zone, is_active boolean DEFAULT true, user_id uuid NOT NULL, role_id uuid, id uuid DEFAULT gen_random_uuid() NOT NULL, assigned_by uuid ); ALTER TABLE public.user_roles OWNER TO postgres; -- -- Name: TABLE user_roles; Type: COMMENT; Schema: public; Owner: postgres -- COMMENT ON TABLE public.user_roles IS 'User role assignments (migrated to UUID)'; -- -- Name: user_sessions; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.user_sessions ( id bigint NOT NULL, session_token character varying(255) NOT NULL, ip_address character varying(45), user_agent text, is_active boolean DEFAULT true, last_activity timestamp with time zone DEFAULT CURRENT_TIMESTAMP, expires_at timestamp with time zone NOT NULL, revoked_at timestamp with time zone, created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP, updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP, user_id uuid NOT NULL ); ALTER TABLE public.user_sessions OWNER TO postgres; -- -- Name: TABLE user_sessions; Type: COMMENT; Schema: public; Owner: postgres -- COMMENT ON TABLE public.user_sessions IS 'User sessions for authentication tracking (alternative to sessions table)'; -- -- Name: COLUMN user_sessions.session_token; Type: COMMENT; Schema: public; Owner: postgres -- COMMENT ON COLUMN public.user_sessions.session_token IS 'Unique session token (hashed)'; -- -- Name: COLUMN user_sessions.last_activity; Type: COMMENT; Schema: public; Owner: postgres -- COMMENT ON COLUMN public.user_sessions.last_activity IS 'Last activity timestamp (updated periodically with debounce)'; -- -- Name: COLUMN user_sessions.revoked_at; Type: COMMENT; Schema: public; Owner: postgres -- COMMENT ON COLUMN public.user_sessions.revoked_at IS 'Timestamp when session was revoked'; -- -- Name: user_sessions_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres -- CREATE SEQUENCE public.user_sessions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER SEQUENCE public.user_sessions_id_seq OWNER TO postgres; -- -- Name: user_sessions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres -- ALTER SEQUENCE public.user_sessions_id_seq OWNED BY public.user_sessions.id; -- -- Name: users; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.users ( username character varying(30) NOT NULL, slug character varying(255), email character varying(255) NOT NULL, password_hash character varying(255), token_version integer DEFAULT 0 NOT NULL, first_name character varying(100), last_name character varying(100), avatar text, bio text, location character varying(100), birthdate timestamp with time zone, gender character varying(20), username_changed_at timestamp with time zone, role character varying(50) DEFAULT 'user'::character varying NOT NULL, is_active boolean DEFAULT true, is_verified boolean DEFAULT false, is_admin boolean DEFAULT false, is_public boolean DEFAULT true, last_login_at timestamp with time zone, created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP, updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP, deleted_at timestamp with time zone, id uuid NOT NULL ); ALTER TABLE public.users OWNER TO postgres; -- -- Name: TABLE users; Type: COMMENT; Schema: public; Owner: postgres -- COMMENT ON TABLE public.users IS 'Core user accounts for authentication and profiles'; -- -- Name: COLUMN users.slug; Type: COMMENT; Schema: public; Owner: postgres -- COMMENT ON COLUMN public.users.slug IS 'URL-friendly unique identifier for user profile'; -- -- Name: COLUMN users.token_version; Type: COMMENT; Schema: public; Owner: postgres -- COMMENT ON COLUMN public.users.token_version IS 'Version number for JWT token invalidation'; -- -- Name: bitrate_adaptation_logs id; Type: DEFAULT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.bitrate_adaptation_logs ALTER COLUMN id SET DEFAULT nextval('public.bitrate_adaptation_logs_id_seq'::regclass); -- -- Name: email_verification_tokens id; Type: DEFAULT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.email_verification_tokens ALTER COLUMN id SET DEFAULT nextval('public.email_verification_tokens_id_seq'::regclass); -- -- Name: hls_streams id; Type: DEFAULT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.hls_streams ALTER COLUMN id SET DEFAULT nextval('public.hls_streams_id_seq'::regclass); -- -- Name: hls_transcode_queue id; Type: DEFAULT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.hls_transcode_queue ALTER COLUMN id SET DEFAULT nextval('public.hls_transcode_queue_id_seq'::regclass); -- -- Name: password_reset_tokens id; Type: DEFAULT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.password_reset_tokens ALTER COLUMN id SET DEFAULT nextval('public.password_reset_tokens_id_seq'::regclass); -- -- Name: playback_analytics id; Type: DEFAULT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.playback_analytics ALTER COLUMN id SET DEFAULT nextval('public.playback_analytics_id_seq'::regclass); -- -- Name: playlist_collaborators id; Type: DEFAULT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.playlist_collaborators ALTER COLUMN id SET DEFAULT nextval('public.playlist_collaborators_id_seq'::regclass); -- -- Name: playlist_follows id; Type: DEFAULT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.playlist_follows ALTER COLUMN id SET DEFAULT nextval('public.playlist_follows_id_seq'::regclass); -- -- Name: refresh_tokens id; Type: DEFAULT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.refresh_tokens ALTER COLUMN id SET DEFAULT nextval('public.refresh_tokens_id_seq'::regclass); -- -- Name: rooms id; Type: DEFAULT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.rooms ALTER COLUMN id SET DEFAULT nextval('public.rooms_id_seq'::regclass); -- -- Name: track_comments id; Type: DEFAULT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.track_comments ALTER COLUMN id SET DEFAULT nextval('public.track_comments_id_seq'::regclass); -- -- Name: track_history id; Type: DEFAULT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.track_history ALTER COLUMN id SET DEFAULT nextval('public.track_history_id_seq'::regclass); -- -- Name: track_likes id; Type: DEFAULT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.track_likes ALTER COLUMN id SET DEFAULT nextval('public.track_likes_id_seq'::regclass); -- -- Name: track_plays id; Type: DEFAULT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.track_plays ALTER COLUMN id SET DEFAULT nextval('public.track_plays_id_seq'::regclass); -- -- Name: track_shares id; Type: DEFAULT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.track_shares ALTER COLUMN id SET DEFAULT nextval('public.track_shares_id_seq'::regclass); -- -- Name: track_versions id; Type: DEFAULT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.track_versions ALTER COLUMN id SET DEFAULT nextval('public.track_versions_id_seq'::regclass); -- -- Name: user_sessions id; Type: DEFAULT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.user_sessions ALTER COLUMN id SET DEFAULT nextval('public.user_sessions_id_seq'::regclass); -- -- Name: admin_settings admin_settings_key_key; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.admin_settings ADD CONSTRAINT admin_settings_key_key UNIQUE (key); -- -- Name: admin_settings admin_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.admin_settings ADD CONSTRAINT admin_settings_pkey PRIMARY KEY (id); -- -- Name: bitrate_adaptation_logs bitrate_adaptation_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.bitrate_adaptation_logs ADD CONSTRAINT bitrate_adaptation_logs_pkey PRIMARY KEY (id); -- -- Name: email_verification_tokens email_verification_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.email_verification_tokens ADD CONSTRAINT email_verification_tokens_pkey PRIMARY KEY (id); -- -- Name: email_verification_tokens email_verification_tokens_token_key; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.email_verification_tokens ADD CONSTRAINT email_verification_tokens_token_key UNIQUE (token); -- -- Name: federated_identities federated_identities_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.federated_identities ADD CONSTRAINT federated_identities_pkey PRIMARY KEY (id); -- -- Name: hls_streams hls_streams_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.hls_streams ADD CONSTRAINT hls_streams_pkey PRIMARY KEY (id); -- -- Name: hls_transcode_queue hls_transcode_queue_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.hls_transcode_queue ADD CONSTRAINT hls_transcode_queue_pkey PRIMARY KEY (id); -- -- Name: password_reset_tokens password_reset_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.password_reset_tokens ADD CONSTRAINT password_reset_tokens_pkey PRIMARY KEY (id); -- -- Name: password_reset_tokens password_reset_tokens_token_key; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.password_reset_tokens ADD CONSTRAINT password_reset_tokens_token_key UNIQUE (token); -- -- Name: permissions permissions_name_key; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.permissions ADD CONSTRAINT permissions_name_key UNIQUE (name); -- -- Name: permissions permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.permissions ADD CONSTRAINT permissions_pkey PRIMARY KEY (id); -- -- Name: playback_analytics playback_analytics_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.playback_analytics ADD CONSTRAINT playback_analytics_pkey PRIMARY KEY (id); -- -- Name: playlist_collaborators playlist_collaborators_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.playlist_collaborators ADD CONSTRAINT playlist_collaborators_pkey PRIMARY KEY (id); -- -- Name: playlist_follows playlist_follows_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.playlist_follows ADD CONSTRAINT playlist_follows_pkey PRIMARY KEY (id); -- -- Name: playlist_tracks playlist_tracks_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.playlist_tracks ADD CONSTRAINT playlist_tracks_pkey PRIMARY KEY (id); -- -- Name: playlists playlists_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.playlists ADD CONSTRAINT playlists_pkey PRIMARY KEY (id); -- -- Name: refresh_tokens refresh_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.refresh_tokens ADD CONSTRAINT refresh_tokens_pkey PRIMARY KEY (id); -- -- Name: role_permissions role_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.role_permissions ADD CONSTRAINT role_permissions_pkey PRIMARY KEY (role_id, permission_id); -- -- Name: roles roles_name_key; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.roles ADD CONSTRAINT roles_name_key UNIQUE (name); -- -- Name: roles roles_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.roles ADD CONSTRAINT roles_pkey PRIMARY KEY (id); -- -- Name: rooms rooms_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.rooms ADD CONSTRAINT rooms_pkey PRIMARY KEY (id); -- -- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.schema_migrations ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version); -- -- Name: track_comments track_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.track_comments ADD CONSTRAINT track_comments_pkey PRIMARY KEY (id); -- -- Name: track_history track_history_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.track_history ADD CONSTRAINT track_history_pkey PRIMARY KEY (id); -- -- Name: track_likes track_likes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.track_likes ADD CONSTRAINT track_likes_pkey PRIMARY KEY (id); -- -- Name: track_plays track_plays_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.track_plays ADD CONSTRAINT track_plays_pkey PRIMARY KEY (id); -- -- Name: track_shares track_shares_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.track_shares ADD CONSTRAINT track_shares_pkey PRIMARY KEY (id); -- -- Name: track_shares track_shares_share_token_key; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.track_shares ADD CONSTRAINT track_shares_share_token_key UNIQUE (share_token); -- -- Name: track_versions track_versions_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.track_versions ADD CONSTRAINT track_versions_pkey PRIMARY KEY (id); -- -- Name: tracks tracks_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.tracks ADD CONSTRAINT tracks_pkey PRIMARY KEY (id); -- -- Name: user_roles user_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.user_roles ADD CONSTRAINT user_roles_pkey PRIMARY KEY (id); -- -- Name: user_sessions user_sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.user_sessions ADD CONSTRAINT user_sessions_pkey PRIMARY KEY (id); -- -- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.users ADD CONSTRAINT users_pkey PRIMARY KEY (id); -- -- Name: idx_bitrate_adaptation_created_at; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_bitrate_adaptation_created_at ON public.bitrate_adaptation_logs USING btree (created_at); -- -- Name: idx_email_verification_tokens_expires_at; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_email_verification_tokens_expires_at ON public.email_verification_tokens USING btree (expires_at); -- -- Name: idx_email_verification_tokens_token; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_email_verification_tokens_token ON public.email_verification_tokens USING btree (token); -- -- Name: idx_federated_identities_provider_id; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_federated_identities_provider_id ON public.federated_identities USING btree (provider, provider_id); -- -- Name: idx_federated_identities_user_id; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_federated_identities_user_id ON public.federated_identities USING btree (user_id); -- -- Name: idx_hls_streams_status; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_hls_streams_status ON public.hls_streams USING btree (status); -- -- Name: idx_hls_transcode_queue_status; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_hls_transcode_queue_status ON public.hls_transcode_queue USING btree (status, priority DESC); -- -- Name: idx_password_reset_tokens_expires_at; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_password_reset_tokens_expires_at ON public.password_reset_tokens USING btree (expires_at); -- -- Name: idx_password_reset_tokens_token; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_password_reset_tokens_token ON public.password_reset_tokens USING btree (token); -- -- Name: idx_playback_analytics_completion; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_playback_analytics_completion ON public.playback_analytics USING btree (completion_rate); -- -- Name: idx_playback_analytics_created_at; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_playback_analytics_created_at ON public.playback_analytics USING btree (created_at); -- -- Name: idx_playlist_collaborators_deleted_at; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_playlist_collaborators_deleted_at ON public.playlist_collaborators USING btree (deleted_at); -- -- Name: idx_playlist_collaborators_user_id; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_playlist_collaborators_user_id ON public.playlist_collaborators USING btree (user_id); -- -- Name: idx_playlist_follows_deleted_at; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_playlist_follows_deleted_at ON public.playlist_follows USING btree (deleted_at); -- -- Name: idx_playlist_follows_user_id; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_playlist_follows_user_id ON public.playlist_follows USING btree (user_id); -- -- Name: idx_playlists_deleted_at; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_playlists_deleted_at ON public.playlists USING btree (deleted_at); -- -- Name: idx_playlists_follower_count; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_playlists_follower_count ON public.playlists USING btree (follower_count); -- -- Name: idx_playlists_user_id; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_playlists_user_id ON public.playlists USING btree (user_id); -- -- Name: idx_refresh_tokens_deleted_at; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_refresh_tokens_deleted_at ON public.refresh_tokens USING btree (deleted_at); -- -- Name: idx_refresh_tokens_expires_at; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_refresh_tokens_expires_at ON public.refresh_tokens USING btree (expires_at) WHERE (deleted_at IS NULL); -- -- Name: idx_refresh_tokens_token_hash; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_refresh_tokens_token_hash ON public.refresh_tokens USING btree (token_hash); -- -- Name: idx_refresh_tokens_user_id; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_refresh_tokens_user_id ON public.refresh_tokens USING btree (user_id); -- -- Name: idx_role_permissions_permission_id; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_role_permissions_permission_id ON public.role_permissions USING btree (permission_id); -- -- Name: idx_role_permissions_role_id; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_role_permissions_role_id ON public.role_permissions USING btree (role_id); -- -- Name: idx_rooms_created_at; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_rooms_created_at ON public.rooms USING btree (created_at DESC); -- -- Name: idx_rooms_deleted_at; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_rooms_deleted_at ON public.rooms USING btree (deleted_at); -- -- Name: idx_rooms_is_active; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_rooms_is_active ON public.rooms USING btree (is_active) WHERE (deleted_at IS NULL); -- -- Name: idx_rooms_room_type; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_rooms_room_type ON public.rooms USING btree (room_type); -- -- Name: idx_track_comments_created_at; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_track_comments_created_at ON public.track_comments USING btree (created_at DESC); -- -- Name: idx_track_comments_parent_id; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_track_comments_parent_id ON public.track_comments USING btree (parent_id); -- -- Name: idx_track_comments_user_id; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_track_comments_user_id ON public.track_comments USING btree (user_id); -- -- Name: idx_track_history_action; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_track_history_action ON public.track_history USING btree (action); -- -- Name: idx_track_history_created_at; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_track_history_created_at ON public.track_history USING btree (created_at DESC); -- -- Name: idx_track_likes_user_id; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_track_likes_user_id ON public.track_likes USING btree (user_id); -- -- Name: idx_track_plays_deleted_at; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_track_plays_deleted_at ON public.track_plays USING btree (deleted_at); -- -- Name: idx_track_plays_played_at; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_track_plays_played_at ON public.track_plays USING btree (played_at DESC); -- -- Name: idx_track_shares_deleted_at; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_track_shares_deleted_at ON public.track_shares USING btree (deleted_at); -- -- Name: idx_track_shares_share_token; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_track_shares_share_token ON public.track_shares USING btree (share_token); -- -- Name: idx_track_shares_user_id; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_track_shares_user_id ON public.track_shares USING btree (user_id); -- -- Name: idx_track_versions_created_at; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_track_versions_created_at ON public.track_versions USING btree (created_at DESC); -- -- Name: idx_track_versions_deleted_at; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_track_versions_deleted_at ON public.track_versions USING btree (deleted_at); -- -- Name: idx_tracks_created_at; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_tracks_created_at ON public.tracks USING btree (created_at); -- -- Name: idx_tracks_is_public; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_tracks_is_public ON public.tracks USING btree (is_public); -- -- Name: idx_tracks_status; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_tracks_status ON public.tracks USING btree (status); -- -- Name: idx_tracks_user_id; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_tracks_user_id ON public.tracks USING btree (user_id); -- -- Name: idx_user_roles_role_id; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_user_roles_role_id ON public.user_roles USING btree (role_id); -- -- Name: idx_user_roles_user_id; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_user_roles_user_id ON public.user_roles USING btree (user_id); -- -- Name: idx_user_sessions_expires_at; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_user_sessions_expires_at ON public.user_sessions USING btree (expires_at); -- -- Name: idx_user_sessions_is_active; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_user_sessions_is_active ON public.user_sessions USING btree (is_active) WHERE (is_active = true); -- -- Name: idx_user_sessions_last_activity; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_user_sessions_last_activity ON public.user_sessions USING btree (last_activity DESC); -- -- Name: idx_user_sessions_token; Type: INDEX; Schema: public; Owner: postgres -- CREATE UNIQUE INDEX idx_user_sessions_token ON public.user_sessions USING btree (session_token); -- -- Name: idx_users_created_at; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_users_created_at ON public.users USING btree (created_at DESC); -- -- Name: idx_users_deleted_at; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_users_deleted_at ON public.users USING btree (deleted_at); -- -- Name: idx_users_email; Type: INDEX; Schema: public; Owner: postgres -- CREATE UNIQUE INDEX idx_users_email ON public.users USING btree (email) WHERE (deleted_at IS NULL); -- -- Name: idx_users_is_active; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_users_is_active ON public.users USING btree (is_active) WHERE (deleted_at IS NULL); -- -- Name: idx_users_is_public; Type: INDEX; Schema: public; Owner: postgres -- CREATE INDEX idx_users_is_public ON public.users USING btree (is_public); -- -- Name: idx_users_slug; Type: INDEX; Schema: public; Owner: postgres -- CREATE UNIQUE INDEX idx_users_slug ON public.users USING btree (slug) WHERE (deleted_at IS NULL); -- -- Name: idx_users_username; Type: INDEX; Schema: public; Owner: postgres -- CREATE UNIQUE INDEX idx_users_username ON public.users USING btree (username) WHERE (deleted_at IS NULL); -- -- Name: federated_identities federated_identities_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.federated_identities ADD CONSTRAINT federated_identities_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: bitrate_adaptation_logs fk_bitrate_adaptation_logs_track; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.bitrate_adaptation_logs ADD CONSTRAINT fk_bitrate_adaptation_logs_track FOREIGN KEY (track_id) REFERENCES public.tracks(id) ON DELETE CASCADE; -- -- Name: bitrate_adaptation_logs fk_bitrate_adaptation_logs_users; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.bitrate_adaptation_logs ADD CONSTRAINT fk_bitrate_adaptation_logs_users FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: email_verification_tokens fk_email_verification_tokens_users; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.email_verification_tokens ADD CONSTRAINT fk_email_verification_tokens_users FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: hls_streams fk_hls_streams_track; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.hls_streams ADD CONSTRAINT fk_hls_streams_track FOREIGN KEY (track_id) REFERENCES public.tracks(id) ON DELETE CASCADE; -- -- Name: hls_transcode_queue fk_hls_transcode_queue_track; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.hls_transcode_queue ADD CONSTRAINT fk_hls_transcode_queue_track FOREIGN KEY (track_id) REFERENCES public.tracks(id) ON DELETE CASCADE; -- -- Name: password_reset_tokens fk_password_reset_tokens_users; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.password_reset_tokens ADD CONSTRAINT fk_password_reset_tokens_users FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: playback_analytics fk_playback_analytics_track; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.playback_analytics ADD CONSTRAINT fk_playback_analytics_track FOREIGN KEY (track_id) REFERENCES public.tracks(id) ON DELETE CASCADE; -- -- Name: playback_analytics fk_playback_analytics_users; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.playback_analytics ADD CONSTRAINT fk_playback_analytics_users FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: playlist_collaborators fk_playlist_collaborators_playlist; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.playlist_collaborators ADD CONSTRAINT fk_playlist_collaborators_playlist FOREIGN KEY (playlist_id) REFERENCES public.playlists(id) ON DELETE CASCADE; -- -- Name: playlist_follows fk_playlist_follows_playlist; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.playlist_follows ADD CONSTRAINT fk_playlist_follows_playlist FOREIGN KEY (playlist_id) REFERENCES public.playlists(id) ON DELETE CASCADE; -- -- Name: playlist_tracks fk_playlist_tracks_playlist; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.playlist_tracks ADD CONSTRAINT fk_playlist_tracks_playlist FOREIGN KEY (playlist_id) REFERENCES public.playlists(id) ON DELETE CASCADE; -- -- Name: playlist_tracks fk_playlist_tracks_track; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.playlist_tracks ADD CONSTRAINT fk_playlist_tracks_track FOREIGN KEY (track_id) REFERENCES public.tracks(id) ON DELETE CASCADE; -- -- Name: playlists fk_playlists_users; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.playlists ADD CONSTRAINT fk_playlists_users FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: track_comments fk_track_comments_track; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.track_comments ADD CONSTRAINT fk_track_comments_track FOREIGN KEY (track_id) REFERENCES public.tracks(id) ON DELETE CASCADE; -- -- Name: track_history fk_track_history_track; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.track_history ADD CONSTRAINT fk_track_history_track FOREIGN KEY (track_id) REFERENCES public.tracks(id) ON DELETE CASCADE; -- -- Name: track_history fk_track_history_users; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.track_history ADD CONSTRAINT fk_track_history_users FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: track_likes fk_track_likes_track; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.track_likes ADD CONSTRAINT fk_track_likes_track FOREIGN KEY (track_id) REFERENCES public.tracks(id) ON DELETE CASCADE; -- -- Name: track_plays fk_track_plays_track; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.track_plays ADD CONSTRAINT fk_track_plays_track FOREIGN KEY (track_id) REFERENCES public.tracks(id) ON DELETE CASCADE; -- -- Name: track_plays fk_track_plays_users; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.track_plays ADD CONSTRAINT fk_track_plays_users FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: track_shares fk_track_shares_track; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.track_shares ADD CONSTRAINT fk_track_shares_track FOREIGN KEY (track_id) REFERENCES public.tracks(id) ON DELETE CASCADE; -- -- Name: track_versions fk_track_versions_track; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.track_versions ADD CONSTRAINT fk_track_versions_track FOREIGN KEY (track_id) REFERENCES public.tracks(id) ON DELETE CASCADE; -- -- Name: tracks fk_tracks_users; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.tracks ADD CONSTRAINT fk_tracks_users FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: user_roles fk_user_roles_users; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.user_roles ADD CONSTRAINT fk_user_roles_users FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: user_sessions fk_user_sessions_users; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.user_sessions ADD CONSTRAINT fk_user_sessions_users FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: role_permissions role_permissions_permission_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.role_permissions ADD CONSTRAINT role_permissions_permission_id_fkey FOREIGN KEY (permission_id) REFERENCES public.permissions(id) ON DELETE CASCADE; -- -- Name: role_permissions role_permissions_role_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.role_permissions ADD CONSTRAINT role_permissions_role_id_fkey FOREIGN KEY (role_id) REFERENCES public.roles(id) ON DELETE CASCADE; -- -- Name: rooms rooms_creator_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.rooms ADD CONSTRAINT rooms_creator_id_fkey FOREIGN KEY (creator_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: rooms rooms_owner_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.rooms ADD CONSTRAINT rooms_owner_id_fkey FOREIGN KEY (owner_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: track_comments track_comments_parent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.track_comments ADD CONSTRAINT track_comments_parent_id_fkey FOREIGN KEY (parent_id) REFERENCES public.track_comments(id) ON DELETE CASCADE; -- -- Name: user_roles user_roles_assigned_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.user_roles ADD CONSTRAINT user_roles_assigned_by_fkey FOREIGN KEY (assigned_by) REFERENCES public.users(id) ON DELETE SET NULL; -- -- Name: user_roles user_roles_role_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.user_roles ADD CONSTRAINT user_roles_role_id_fkey FOREIGN KEY (role_id) REFERENCES public.roles(id) ON DELETE CASCADE; -- -- PostgreSQL database dump complete --