{ "id": "104fe2b6-6fff-4ce6-927b-c9bebba88dc6", "prevId": "00000000-0000-0000-0000-000000000000", "version": "7", "dialect": "postgresql", "tables": { "public.api_token_topics": { "name": "api_token_topics", "schema": "", "columns": { "token_id": { "name": "token_id", "type": "uuid", "primaryKey": false, "notNull": true }, "topic_id": { "name": "topic_id", "type": "uuid", "primaryKey": false, "notNull": true } }, "indexes": {}, "foreignKeys": { "api_token_topics_token_id_api_tokens_id_fk": { "name": "api_token_topics_token_id_api_tokens_id_fk", "tableFrom": "api_token_topics", "tableTo": "api_tokens", "columnsFrom": [ "token_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "api_token_topics_topic_id_topics_id_fk": { "name": "api_token_topics_topic_id_topics_id_fk", "tableFrom": "api_token_topics", "tableTo": "topics", "columnsFrom": [ "topic_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": { "api_token_topics_token_id_topic_id_pk": { "name": "api_token_topics_token_id_topic_id_pk", "columns": [ "token_id", "topic_id" ] } }, "uniqueConstraints": {} }, "public.api_tokens": { "name": "api_tokens", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "name": { "name": "name", "type": "text", "primaryKey": false, "notNull": true }, "token_hash": { "name": "token_hash", "type": "text", "primaryKey": false, "notNull": true }, "token_prefix": { "name": "token_prefix", "type": "text", "primaryKey": false, "notNull": true }, "allowed_source": { "name": "allowed_source", "type": "text", "primaryKey": false, "notNull": false }, "allowed_cidrs": { "name": "allowed_cidrs", "type": "text[]", "primaryKey": false, "notNull": false }, "expires_at": { "name": "expires_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": false }, "revoked_at": { "name": "revoked_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": false }, "created_by": { "name": "created_by", "type": "uuid", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "last_used_at": { "name": "last_used_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": false }, "usage_count": { "name": "usage_count", "type": "bigint", "primaryKey": false, "notNull": true, "default": 0 } }, "indexes": { "api_tokens_token_hash_key": { "name": "api_tokens_token_hash_key", "columns": [ { "expression": "token_hash", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "api_tokens_created_by_users_id_fk": { "name": "api_tokens_created_by_users_id_fk", "tableFrom": "api_tokens", "tableTo": "users", "columnsFrom": [ "created_by" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {} }, "public.audit_log": { "name": "audit_log", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "actor_user_id": { "name": "actor_user_id", "type": "uuid", "primaryKey": false, "notNull": false }, "actor_token_id": { "name": "actor_token_id", "type": "uuid", "primaryKey": false, "notNull": false }, "action": { "name": "action", "type": "text", "primaryKey": false, "notNull": true }, "target_type": { "name": "target_type", "type": "text", "primaryKey": false, "notNull": false }, "target_id": { "name": "target_id", "type": "text", "primaryKey": false, "notNull": false }, "metadata": { "name": "metadata", "type": "jsonb", "primaryKey": false, "notNull": false }, "ip_address": { "name": "ip_address", "type": "inet", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "audit_log_created_idx": { "name": "audit_log_created_idx", "columns": [ { "expression": "created_at", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} }, "audit_log_action_idx": { "name": "audit_log_action_idx", "columns": [ { "expression": "action", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "audit_log_actor_user_id_users_id_fk": { "name": "audit_log_actor_user_id_users_id_fk", "tableFrom": "audit_log", "tableTo": "users", "columnsFrom": [ "actor_user_id" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" }, "audit_log_actor_token_id_api_tokens_id_fk": { "name": "audit_log_actor_token_id_api_tokens_id_fk", "tableFrom": "audit_log", "tableTo": "api_tokens", "columnsFrom": [ "actor_token_id" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {} }, "public.notifications": { "name": "notifications", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "topic_id": { "name": "topic_id", "type": "uuid", "primaryKey": false, "notNull": true }, "source": { "name": "source", "type": "text", "primaryKey": false, "notNull": true }, "title": { "name": "title", "type": "text", "primaryKey": false, "notNull": true }, "message": { "name": "message", "type": "text", "primaryKey": false, "notNull": true }, "external_url": { "name": "external_url", "type": "text", "primaryKey": false, "notNull": false }, "image_url": { "name": "image_url", "type": "text", "primaryKey": false, "notNull": false }, "attachment_filename": { "name": "attachment_filename", "type": "text", "primaryKey": false, "notNull": false }, "attachment_content_type": { "name": "attachment_content_type", "type": "text", "primaryKey": false, "notNull": false }, "attachment_size_bytes": { "name": "attachment_size_bytes", "type": "bigint", "primaryKey": false, "notNull": false }, "deduplication_key": { "name": "deduplication_key", "type": "text", "primaryKey": false, "notNull": false }, "occurrence_count": { "name": "occurrence_count", "type": "integer", "primaryKey": false, "notNull": true, "default": 1 }, "raw_priority": { "name": "raw_priority", "type": "text", "primaryKey": false, "notNull": false }, "sender_token_id": { "name": "sender_token_id", "type": "uuid", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "notifications_topic_created_idx": { "name": "notifications_topic_created_idx", "columns": [ { "expression": "topic_id", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "created_at", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} }, "notifications_dedup_idx": { "name": "notifications_dedup_idx", "columns": [ { "expression": "deduplication_key", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "topic_id", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "created_at", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} }, "notifications_created_idx": { "name": "notifications_created_idx", "columns": [ { "expression": "created_at", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "notifications_topic_id_topics_id_fk": { "name": "notifications_topic_id_topics_id_fk", "tableFrom": "notifications", "tableTo": "topics", "columnsFrom": [ "topic_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "notifications_sender_token_id_api_tokens_id_fk": { "name": "notifications_sender_token_id_api_tokens_id_fk", "tableFrom": "notifications", "tableTo": "api_tokens", "columnsFrom": [ "sender_token_id" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {} }, "public.push_delivery_attempts": { "name": "push_delivery_attempts", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "notification_id": { "name": "notification_id", "type": "uuid", "primaryKey": false, "notNull": true }, "push_subscription_id": { "name": "push_subscription_id", "type": "uuid", "primaryKey": false, "notNull": true }, "status": { "name": "status", "type": "push_delivery_status", "typeSchema": "public", "primaryKey": false, "notNull": true }, "http_status": { "name": "http_status", "type": "integer", "primaryKey": false, "notNull": false }, "error_message": { "name": "error_message", "type": "text", "primaryKey": false, "notNull": false }, "retry_count": { "name": "retry_count", "type": "integer", "primaryKey": false, "notNull": true, "default": 0 }, "attempted_at": { "name": "attempted_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "push_delivery_attempts_notification_idx": { "name": "push_delivery_attempts_notification_idx", "columns": [ { "expression": "notification_id", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} }, "push_delivery_attempts_subscription_idx": { "name": "push_delivery_attempts_subscription_idx", "columns": [ { "expression": "push_subscription_id", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "attempted_at", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "push_delivery_attempts_notification_id_notifications_id_fk": { "name": "push_delivery_attempts_notification_id_notifications_id_fk", "tableFrom": "push_delivery_attempts", "tableTo": "notifications", "columnsFrom": [ "notification_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "push_delivery_attempts_push_subscription_id_push_subscriptions_id_fk": { "name": "push_delivery_attempts_push_subscription_id_push_subscriptions_id_fk", "tableFrom": "push_delivery_attempts", "tableTo": "push_subscriptions", "columnsFrom": [ "push_subscription_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {} }, "public.push_subscriptions": { "name": "push_subscriptions", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "user_id": { "name": "user_id", "type": "uuid", "primaryKey": false, "notNull": true }, "endpoint": { "name": "endpoint", "type": "text", "primaryKey": false, "notNull": true }, "p256dh": { "name": "p256dh", "type": "text", "primaryKey": false, "notNull": true }, "auth": { "name": "auth", "type": "text", "primaryKey": false, "notNull": true }, "user_agent": { "name": "user_agent", "type": "text", "primaryKey": false, "notNull": false }, "device_label": { "name": "device_label", "type": "text", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "last_seen_at": { "name": "last_seen_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "disabled_at": { "name": "disabled_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": false } }, "indexes": { "push_subscriptions_endpoint_key": { "name": "push_subscriptions_endpoint_key", "columns": [ { "expression": "endpoint", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "push_subscriptions_user_id_users_id_fk": { "name": "push_subscriptions_user_id_users_id_fk", "tableFrom": "push_subscriptions", "tableTo": "users", "columnsFrom": [ "user_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {} }, "public.system_settings": { "name": "system_settings", "schema": "", "columns": { "key": { "name": "key", "type": "text", "primaryKey": true, "notNull": true }, "value": { "name": "value", "type": "jsonb", "primaryKey": false, "notNull": true }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": {}, "foreignKeys": {}, "compositePrimaryKeys": {}, "uniqueConstraints": {} }, "public.topic_members": { "name": "topic_members", "schema": "", "columns": { "topic_id": { "name": "topic_id", "type": "uuid", "primaryKey": false, "notNull": true }, "user_id": { "name": "user_id", "type": "uuid", "primaryKey": false, "notNull": true } }, "indexes": {}, "foreignKeys": { "topic_members_topic_id_topics_id_fk": { "name": "topic_members_topic_id_topics_id_fk", "tableFrom": "topic_members", "tableTo": "topics", "columnsFrom": [ "topic_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "topic_members_user_id_users_id_fk": { "name": "topic_members_user_id_users_id_fk", "tableFrom": "topic_members", "tableTo": "users", "columnsFrom": [ "user_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": { "topic_members_topic_id_user_id_pk": { "name": "topic_members_topic_id_user_id_pk", "columns": [ "topic_id", "user_id" ] } }, "uniqueConstraints": {} }, "public.topics": { "name": "topics", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "slug": { "name": "slug", "type": "text", "primaryKey": false, "notNull": true }, "display_name": { "name": "display_name", "type": "text", "primaryKey": false, "notNull": true }, "description": { "name": "description", "type": "text", "primaryKey": false, "notNull": false }, "icon": { "name": "icon", "type": "text", "primaryKey": false, "notNull": false }, "accent_color": { "name": "accent_color", "type": "text", "primaryKey": false, "notNull": false }, "retention_days": { "name": "retention_days", "type": "integer", "primaryKey": false, "notNull": false }, "restricted": { "name": "restricted", "type": "boolean", "primaryKey": false, "notNull": true, "default": false }, "created_by": { "name": "created_by", "type": "uuid", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "archived_at": { "name": "archived_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": false } }, "indexes": { "topics_slug_key": { "name": "topics_slug_key", "columns": [ { "expression": "slug", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "topics_created_by_users_id_fk": { "name": "topics_created_by_users_id_fk", "tableFrom": "topics", "tableTo": "users", "columnsFrom": [ "created_by" ], "columnsTo": [ "id" ], "onDelete": "set null", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {} }, "public.user_notification_state": { "name": "user_notification_state", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "user_id": { "name": "user_id", "type": "uuid", "primaryKey": false, "notNull": true }, "notification_id": { "name": "notification_id", "type": "uuid", "primaryKey": false, "notNull": true }, "read": { "name": "read", "type": "boolean", "primaryKey": false, "notNull": true, "default": false }, "read_at": { "name": "read_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": false }, "starred": { "name": "starred", "type": "boolean", "primaryKey": false, "notNull": true, "default": false }, "starred_at": { "name": "starred_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": false } }, "indexes": { "user_notification_state_user_notification_key": { "name": "user_notification_state_user_notification_key", "columns": [ { "expression": "user_id", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "notification_id", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "concurrently": false, "method": "btree", "with": {} }, "user_notification_state_user_read_idx": { "name": "user_notification_state_user_read_idx", "columns": [ { "expression": "user_id", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "read", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} }, "user_notification_state_user_starred_idx": { "name": "user_notification_state_user_starred_idx", "columns": [ { "expression": "user_id", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "starred", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "user_notification_state_user_id_users_id_fk": { "name": "user_notification_state_user_id_users_id_fk", "tableFrom": "user_notification_state", "tableTo": "users", "columnsFrom": [ "user_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "user_notification_state_notification_id_notifications_id_fk": { "name": "user_notification_state_notification_id_notifications_id_fk", "tableFrom": "user_notification_state", "tableTo": "notifications", "columnsFrom": [ "notification_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {} }, "public.user_topic_subscriptions": { "name": "user_topic_subscriptions", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "user_id": { "name": "user_id", "type": "uuid", "primaryKey": false, "notNull": true }, "topic_id": { "name": "topic_id", "type": "uuid", "primaryKey": false, "notNull": true }, "push_enabled": { "name": "push_enabled", "type": "boolean", "primaryKey": false, "notNull": true, "default": true }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" } }, "indexes": { "user_topic_subscriptions_user_topic_key": { "name": "user_topic_subscriptions_user_topic_key", "columns": [ { "expression": "user_id", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "topic_id", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { "user_topic_subscriptions_user_id_users_id_fk": { "name": "user_topic_subscriptions_user_id_users_id_fk", "tableFrom": "user_topic_subscriptions", "tableTo": "users", "columnsFrom": [ "user_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" }, "user_topic_subscriptions_topic_id_topics_id_fk": { "name": "user_topic_subscriptions_topic_id_topics_id_fk", "tableFrom": "user_topic_subscriptions", "tableTo": "topics", "columnsFrom": [ "topic_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {} }, "public.users": { "name": "users", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "email": { "name": "email", "type": "text", "primaryKey": false, "notNull": true }, "display_name": { "name": "display_name", "type": "text", "primaryKey": false, "notNull": true }, "avatar_url": { "name": "avatar_url", "type": "text", "primaryKey": false, "notNull": false }, "role": { "name": "role", "type": "user_role", "typeSchema": "public", "primaryKey": false, "notNull": true, "default": "'user'" }, "auth_subject": { "name": "auth_subject", "type": "text", "primaryKey": false, "notNull": true }, "auth_issuer": { "name": "auth_issuer", "type": "text", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, "last_login_at": { "name": "last_login_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": false } }, "indexes": { "users_email_key": { "name": "users_email_key", "columns": [ { "expression": "email", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "concurrently": false, "method": "btree", "with": {} }, "users_issuer_subject_key": { "name": "users_issuer_subject_key", "columns": [ { "expression": "auth_issuer", "isExpression": false, "asc": true, "nulls": "last" }, { "expression": "auth_subject", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": {}, "compositePrimaryKeys": {}, "uniqueConstraints": {} } }, "enums": { "public.push_delivery_status": { "name": "push_delivery_status", "schema": "public", "values": [ "pending", "accepted_by_push_service", "failed", "invalid_subscription", "expired" ] }, "public.user_role": { "name": "user_role", "schema": "public", "values": [ "admin", "user" ] } }, "schemas": {}, "sequences": {}, "_meta": { "columns": {}, "schemas": {}, "tables": {} } }