-- CreateEnum CREATE TYPE "Sport" AS ENUM ('football', 'basketball'); -- CreateEnum CREATE TYPE "UserRole" AS ENUM ('user', 'superadmin'); -- CreateEnum CREATE TYPE "SubscriptionStatus" AS ENUM ('free', 'active', 'expired'); -- CreateEnum CREATE TYPE "PlayerPosition" AS ENUM ('goalkeeper', 'defender', 'midfielder', 'striker'); -- CreateEnum CREATE TYPE "EventType" AS ENUM ('goal', 'card', 'substitute'); -- CreateEnum CREATE TYPE "MatchPosition" AS ENUM ('home', 'away'); -- CreateTable CREATE TABLE "countries" ( "id" TEXT NOT NULL, "name" TEXT NOT NULL, "flag_url" TEXT, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "countries_pkey" PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "leagues" ( "id" TEXT NOT NULL, "name" TEXT NOT NULL, "country_id" TEXT, "sport" "Sport" NOT NULL, "competition_slug" TEXT, "code" TEXT, "logo_url" TEXT, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "leagues_pkey" PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "teams" ( "id" TEXT NOT NULL, "name" TEXT NOT NULL, "slug" TEXT, "sport" "Sport" NOT NULL, "logo_url" TEXT, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "teams_pkey" PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "players" ( "id" TEXT NOT NULL, "name" TEXT NOT NULL, "slug" TEXT, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "players_pkey" PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "matches" ( "id" TEXT NOT NULL, "league_id" TEXT, "home_team_id" TEXT, "away_team_id" TEXT, "sport" "Sport" NOT NULL, "match_name" TEXT, "match_slug" TEXT, "mst_utc" BIGINT NOT NULL, "status" TEXT, "state" TEXT, "score_home" INTEGER, "score_away" INTEGER, "ht_score_home" INTEGER, "ht_score_away" INTEGER, "winner" TEXT, "iddaa_code" TEXT, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" TIMESTAMP(3) NOT NULL, CONSTRAINT "matches_pkey" PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "odd_categories" ( "db_id" SERIAL NOT NULL, "match_id" TEXT NOT NULL, "category_json_id" INTEGER, "name" TEXT, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "odd_categories_pkey" PRIMARY KEY ("db_id") ); -- CreateTable CREATE TABLE "odd_selections" ( "db_id" SERIAL NOT NULL, "odd_category_db_id" INTEGER NOT NULL, "name" TEXT, "odd_value" TEXT, "position" TEXT, "sov" DOUBLE PRECISION, "state" TEXT, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "odd_selections_pkey" PRIMARY KEY ("db_id") ); -- CreateTable CREATE TABLE "match_team_stats" ( "id" SERIAL NOT NULL, "match_id" TEXT NOT NULL, "team_id" TEXT NOT NULL, "possession_percentage" DOUBLE PRECISION, "shots_on_target" INTEGER, "shots_off_target" INTEGER, "total_shots" INTEGER, "total_passes" INTEGER, "corners" INTEGER, "fouls" INTEGER, "offsides" INTEGER, "points" INTEGER, "rebounds" INTEGER, "assists" INTEGER, "fg_made" INTEGER, "fg_attempted" INTEGER, "three_pt_made" INTEGER, "three_pt_attempted" INTEGER, "ft_made" INTEGER, "ft_attempted" INTEGER, "steals" INTEGER, "blocks" INTEGER, "turnovers" INTEGER, "q1_score" INTEGER, "q2_score" INTEGER, "q3_score" INTEGER, "q4_score" INTEGER, "ot_score" INTEGER, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "match_team_stats_pkey" PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "match_player_participation" ( "id" SERIAL NOT NULL, "match_id" TEXT NOT NULL, "player_id" TEXT NOT NULL, "team_id" TEXT NOT NULL, "position" "PlayerPosition", "shirt_number" INTEGER, "is_starting" BOOLEAN NOT NULL DEFAULT true, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "match_player_participation_pkey" PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "match_player_events" ( "id" SERIAL NOT NULL, "match_id" TEXT NOT NULL, "player_id" TEXT NOT NULL, "team_id" TEXT NOT NULL, "event_type" "EventType" NOT NULL, "event_subtype" TEXT, "time_minute" TEXT NOT NULL, "time_seconds" INTEGER, "period_id" INTEGER, "assist_player_id" TEXT, "score_after" TEXT, "player_out_id" TEXT, "position" "MatchPosition", "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "match_player_events_pkey" PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "match_player_stats" ( "id" SERIAL NOT NULL, "match_id" TEXT NOT NULL, "player_id" TEXT NOT NULL, "team_id" TEXT NOT NULL, "minutes" TEXT, "points" INTEGER, "rebounds" INTEGER, "assists" INTEGER, "steals" INTEGER, "blocks" INTEGER, "turnovers" INTEGER, "fg_made" INTEGER, "fg_attempted" INTEGER, "three_pt_made" INTEGER, "three_pt_attempted" INTEGER, "ft_made" INTEGER, "ft_attempted" INTEGER, "fouls" INTEGER, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "match_player_stats_pkey" PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "match_officials" ( "id" SERIAL NOT NULL, "match_id" TEXT NOT NULL, "name" TEXT NOT NULL, "role_id" INTEGER NOT NULL, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "match_officials_pkey" PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "official_roles" ( "id" SERIAL NOT NULL, "name" TEXT NOT NULL, CONSTRAINT "official_roles_pkey" PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "live_matches" ( "id" TEXT NOT NULL, "league_id" TEXT, "home_team_id" TEXT, "away_team_id" TEXT, "sport" TEXT, "match_name" TEXT, "match_slug" TEXT, "mst_utc" BIGINT, "status" TEXT, "state" TEXT, "substate" TEXT, "score_home" INTEGER, "score_away" INTEGER, "json_data" JSONB, "updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "is_processed_by_bot" BOOLEAN NOT NULL DEFAULT false, CONSTRAINT "live_matches_pkey" PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "predictions" ( "match_id" TEXT NOT NULL, "prediction_json" JSONB NOT NULL, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" TIMESTAMP(3) NOT NULL, CONSTRAINT "predictions_pkey" PRIMARY KEY ("match_id") ); -- CreateTable CREATE TABLE "ai_predictions_log" ( "id" SERIAL NOT NULL, "match_id" TEXT NOT NULL, "model_version" TEXT NOT NULL, "recommended_bets" JSONB, "confidence_score" DOUBLE PRECISION, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "is_resolved" BOOLEAN NOT NULL DEFAULT false, "actual_result" TEXT, "is_correct" BOOLEAN, "accuracy_score" DOUBLE PRECISION, CONSTRAINT "ai_predictions_log_pkey" PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "users" ( "id" TEXT NOT NULL, "email" TEXT NOT NULL, "password_hash" TEXT NOT NULL, "first_name" TEXT, "last_name" TEXT, "role" "UserRole" NOT NULL DEFAULT 'user', "subscription_status" "SubscriptionStatus" NOT NULL DEFAULT 'free', "subscription_expires_at" TIMESTAMP(3), "encrypted_api_key" TEXT, "is_active" BOOLEAN NOT NULL DEFAULT true, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" TIMESTAMP(3) NOT NULL, "deleted_at" TIMESTAMP(3), CONSTRAINT "users_pkey" PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "usage_limits" ( "id" SERIAL NOT NULL, "user_id" TEXT NOT NULL, "analysis_count" INTEGER NOT NULL DEFAULT 0, "coupon_count" INTEGER NOT NULL DEFAULT 0, "last_reset_date" DATE NOT NULL, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" TIMESTAMP(3) NOT NULL, CONSTRAINT "usage_limits_pkey" PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "analyses" ( "id" SERIAL NOT NULL, "user_id" TEXT NOT NULL, "match_ids" TEXT NOT NULL, "analysis_result_json" TEXT NOT NULL, "is_deleted" BOOLEAN NOT NULL DEFAULT false, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "analyses_pkey" PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "refresh_tokens" ( "id" TEXT NOT NULL, "token" TEXT NOT NULL, "user_id" TEXT NOT NULL, "expires_at" TIMESTAMP(3) NOT NULL, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "refresh_tokens_pkey" PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "app_settings" ( "key" TEXT NOT NULL, "value" TEXT, "updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "app_settings_pkey" PRIMARY KEY ("key") ); -- CreateTable CREATE TABLE "translations" ( "id" TEXT NOT NULL, "key" TEXT NOT NULL, "locale" TEXT NOT NULL, "value" TEXT NOT NULL, "namespace" TEXT NOT NULL DEFAULT 'common', "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" TIMESTAMP(3) NOT NULL, CONSTRAINT "translations_pkey" PRIMARY KEY ("id") ); -- CreateIndex CREATE UNIQUE INDEX "countries_name_key" ON "countries"("name"); -- CreateIndex CREATE INDEX "leagues_sport_idx" ON "leagues"("sport"); -- CreateIndex CREATE INDEX "leagues_country_id_idx" ON "leagues"("country_id"); -- CreateIndex CREATE UNIQUE INDEX "leagues_name_country_id_sport_key" ON "leagues"("name", "country_id", "sport"); -- CreateIndex CREATE INDEX "teams_sport_idx" ON "teams"("sport"); -- CreateIndex CREATE INDEX "teams_name_idx" ON "teams"("name"); -- CreateIndex CREATE UNIQUE INDEX "players_slug_key" ON "players"("slug"); -- CreateIndex CREATE INDEX "players_name_idx" ON "players"("name"); -- CreateIndex CREATE INDEX "matches_mst_utc_idx" ON "matches"("mst_utc" DESC); -- CreateIndex CREATE INDEX "matches_sport_idx" ON "matches"("sport"); -- CreateIndex CREATE INDEX "matches_state_idx" ON "matches"("state"); -- CreateIndex CREATE INDEX "matches_league_id_idx" ON "matches"("league_id"); -- CreateIndex CREATE INDEX "matches_home_team_id_idx" ON "matches"("home_team_id"); -- CreateIndex CREATE INDEX "matches_away_team_id_idx" ON "matches"("away_team_id"); -- CreateIndex CREATE INDEX "matches_iddaa_code_idx" ON "matches"("iddaa_code"); -- CreateIndex CREATE INDEX "odd_categories_match_id_idx" ON "odd_categories"("match_id"); -- CreateIndex CREATE INDEX "odd_selections_odd_category_db_id_idx" ON "odd_selections"("odd_category_db_id"); -- CreateIndex CREATE INDEX "match_team_stats_match_id_idx" ON "match_team_stats"("match_id"); -- CreateIndex CREATE INDEX "match_team_stats_team_id_idx" ON "match_team_stats"("team_id"); -- CreateIndex CREATE UNIQUE INDEX "match_team_stats_match_id_team_id_key" ON "match_team_stats"("match_id", "team_id"); -- CreateIndex CREATE INDEX "match_player_participation_match_id_idx" ON "match_player_participation"("match_id"); -- CreateIndex CREATE INDEX "match_player_participation_player_id_idx" ON "match_player_participation"("player_id"); -- CreateIndex CREATE INDEX "match_player_participation_team_id_idx" ON "match_player_participation"("team_id"); -- CreateIndex CREATE UNIQUE INDEX "match_player_participation_match_id_player_id_team_id_key" ON "match_player_participation"("match_id", "player_id", "team_id"); -- CreateIndex CREATE INDEX "match_player_events_match_id_idx" ON "match_player_events"("match_id"); -- CreateIndex CREATE INDEX "match_player_events_player_id_idx" ON "match_player_events"("player_id"); -- CreateIndex CREATE INDEX "match_player_events_team_id_idx" ON "match_player_events"("team_id"); -- CreateIndex CREATE INDEX "match_player_events_event_type_idx" ON "match_player_events"("event_type"); -- CreateIndex CREATE INDEX "match_player_events_assist_player_id_idx" ON "match_player_events"("assist_player_id"); -- CreateIndex CREATE INDEX "match_player_stats_match_id_idx" ON "match_player_stats"("match_id"); -- CreateIndex CREATE UNIQUE INDEX "match_player_stats_match_id_player_id_team_id_key" ON "match_player_stats"("match_id", "player_id", "team_id"); -- CreateIndex CREATE INDEX "match_officials_match_id_idx" ON "match_officials"("match_id"); -- CreateIndex CREATE INDEX "match_officials_role_id_idx" ON "match_officials"("role_id"); -- CreateIndex CREATE UNIQUE INDEX "match_officials_match_id_name_role_id_key" ON "match_officials"("match_id", "name", "role_id"); -- CreateIndex CREATE UNIQUE INDEX "official_roles_name_key" ON "official_roles"("name"); -- CreateIndex CREATE INDEX "live_matches_mst_utc_idx" ON "live_matches"("mst_utc" ASC); -- CreateIndex CREATE INDEX "live_matches_state_idx" ON "live_matches"("state"); -- CreateIndex CREATE INDEX "live_matches_is_processed_by_bot_idx" ON "live_matches"("is_processed_by_bot"); -- CreateIndex CREATE INDEX "ai_predictions_log_match_id_idx" ON "ai_predictions_log"("match_id"); -- CreateIndex CREATE INDEX "ai_predictions_log_created_at_idx" ON "ai_predictions_log"("created_at" DESC); -- CreateIndex CREATE UNIQUE INDEX "users_email_key" ON "users"("email"); -- CreateIndex CREATE INDEX "users_email_idx" ON "users"("email"); -- CreateIndex CREATE INDEX "users_subscription_status_subscription_expires_at_idx" ON "users"("subscription_status", "subscription_expires_at"); -- CreateIndex CREATE UNIQUE INDEX "usage_limits_user_id_key" ON "usage_limits"("user_id"); -- CreateIndex CREATE INDEX "usage_limits_user_id_idx" ON "usage_limits"("user_id"); -- CreateIndex CREATE INDEX "usage_limits_last_reset_date_idx" ON "usage_limits"("last_reset_date"); -- CreateIndex CREATE INDEX "analyses_user_id_idx" ON "analyses"("user_id"); -- CreateIndex CREATE INDEX "analyses_created_at_idx" ON "analyses"("created_at" DESC); -- CreateIndex CREATE UNIQUE INDEX "refresh_tokens_token_key" ON "refresh_tokens"("token"); -- CreateIndex CREATE INDEX "refresh_tokens_token_idx" ON "refresh_tokens"("token"); -- CreateIndex CREATE INDEX "refresh_tokens_user_id_idx" ON "refresh_tokens"("user_id"); -- CreateIndex CREATE INDEX "translations_key_idx" ON "translations"("key"); -- CreateIndex CREATE INDEX "translations_locale_idx" ON "translations"("locale"); -- CreateIndex CREATE INDEX "translations_namespace_idx" ON "translations"("namespace"); -- CreateIndex CREATE UNIQUE INDEX "translations_key_locale_namespace_key" ON "translations"("key", "locale", "namespace"); -- AddForeignKey ALTER TABLE "leagues" ADD CONSTRAINT "leagues_country_id_fkey" FOREIGN KEY ("country_id") REFERENCES "countries"("id") ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "matches" ADD CONSTRAINT "matches_league_id_fkey" FOREIGN KEY ("league_id") REFERENCES "leagues"("id") ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "matches" ADD CONSTRAINT "matches_home_team_id_fkey" FOREIGN KEY ("home_team_id") REFERENCES "teams"("id") ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "matches" ADD CONSTRAINT "matches_away_team_id_fkey" FOREIGN KEY ("away_team_id") REFERENCES "teams"("id") ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "odd_categories" ADD CONSTRAINT "odd_categories_match_id_fkey" FOREIGN KEY ("match_id") REFERENCES "matches"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "odd_selections" ADD CONSTRAINT "odd_selections_odd_category_db_id_fkey" FOREIGN KEY ("odd_category_db_id") REFERENCES "odd_categories"("db_id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "match_team_stats" ADD CONSTRAINT "match_team_stats_match_id_fkey" FOREIGN KEY ("match_id") REFERENCES "matches"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "match_team_stats" ADD CONSTRAINT "match_team_stats_team_id_fkey" FOREIGN KEY ("team_id") REFERENCES "teams"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "match_player_participation" ADD CONSTRAINT "match_player_participation_match_id_fkey" FOREIGN KEY ("match_id") REFERENCES "matches"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "match_player_participation" ADD CONSTRAINT "match_player_participation_player_id_fkey" FOREIGN KEY ("player_id") REFERENCES "players"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "match_player_participation" ADD CONSTRAINT "match_player_participation_team_id_fkey" FOREIGN KEY ("team_id") REFERENCES "teams"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "match_player_events" ADD CONSTRAINT "match_player_events_match_id_fkey" FOREIGN KEY ("match_id") REFERENCES "matches"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "match_player_events" ADD CONSTRAINT "match_player_events_player_id_fkey" FOREIGN KEY ("player_id") REFERENCES "players"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "match_player_events" ADD CONSTRAINT "match_player_events_team_id_fkey" FOREIGN KEY ("team_id") REFERENCES "teams"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "match_player_events" ADD CONSTRAINT "match_player_events_assist_player_id_fkey" FOREIGN KEY ("assist_player_id") REFERENCES "players"("id") ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "match_player_events" ADD CONSTRAINT "match_player_events_player_out_id_fkey" FOREIGN KEY ("player_out_id") REFERENCES "players"("id") ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "match_player_stats" ADD CONSTRAINT "match_player_stats_match_id_fkey" FOREIGN KEY ("match_id") REFERENCES "matches"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "match_player_stats" ADD CONSTRAINT "match_player_stats_player_id_fkey" FOREIGN KEY ("player_id") REFERENCES "players"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "match_player_stats" ADD CONSTRAINT "match_player_stats_team_id_fkey" FOREIGN KEY ("team_id") REFERENCES "teams"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "match_officials" ADD CONSTRAINT "match_officials_match_id_fkey" FOREIGN KEY ("match_id") REFERENCES "matches"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "match_officials" ADD CONSTRAINT "match_officials_role_id_fkey" FOREIGN KEY ("role_id") REFERENCES "official_roles"("id") ON DELETE RESTRICT ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "live_matches" ADD CONSTRAINT "live_matches_league_id_fkey" FOREIGN KEY ("league_id") REFERENCES "leagues"("id") ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "live_matches" ADD CONSTRAINT "live_matches_home_team_id_fkey" FOREIGN KEY ("home_team_id") REFERENCES "teams"("id") ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "live_matches" ADD CONSTRAINT "live_matches_away_team_id_fkey" FOREIGN KEY ("away_team_id") REFERENCES "teams"("id") ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "predictions" ADD CONSTRAINT "predictions_match_id_fkey" FOREIGN KEY ("match_id") REFERENCES "matches"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "usage_limits" ADD CONSTRAINT "usage_limits_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "analyses" ADD CONSTRAINT "analyses_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "refresh_tokens" ADD CONSTRAINT "refresh_tokens_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;