5 Commits

Author SHA1 Message Date
Donat Magda 9ba8c95142 save 2025-11-26 01:42:25 +01:00
Donat Magda a9546dcc63 save 2025-11-26 01:42:07 +01:00
Donat Magda d7b47f2abe save 2025-11-26 01:41:54 +01:00
Donat Magda e29216e895 Update deployment files: fix nginx proxy, update SQL schema, consolidate to single images tar 2025-11-26 00:27:14 +01:00
Donat Magda 5eb4d3eef7 Fix: Use .js extension for entities in production, fix nginx proxy path 2025-11-26 00:05:06 +01:00
16 changed files with 875 additions and 508 deletions
Binary file not shown.
@@ -1,6 +1,9 @@
import { DataSource } from 'typeorm'; import { DataSource } from 'typeorm';
import { join } from 'path'; import { join } from 'path';
// Use .js extension in production (compiled) and .ts in development
const ext = __filename.endsWith('.js') ? 'js' : 'ts';
export const AppDataSource = new DataSource({ export const AppDataSource = new DataSource({
type: 'postgres', type: 'postgres',
host: process.env.DB_HOST || 'localhost', host: process.env.DB_HOST || 'localhost',
@@ -10,8 +13,8 @@ export const AppDataSource = new DataSource({
database: process.env.DB_NAME || 'serpentrace', database: process.env.DB_NAME || 'serpentrace',
synchronize: false, // Set to false when using migrations synchronize: false, // Set to false when using migrations
logging: process.env.NODE_ENV === 'development', logging: process.env.NODE_ENV === 'development',
entities: [join(__dirname, '../Domain/**/*Aggregate.ts')], entities: [join(__dirname, `../Domain/**/*Aggregate.${ext}`)],
migrations: [join(__dirname, './Migrations/*.ts')], migrations: [join(__dirname, `./Migrations/*.${ext}`)],
migrationsTableName: 'migrations', migrationsTableName: 'migrations',
migrationsRun: false // Let migrations run manually migrationsRun: false // Let migrations run manually
}); });
+3
View File
@@ -38,6 +38,9 @@ RUN npm ci --only=production && npm cache clean --force
COPY --from=builder /app/dist ./dist COPY --from=builder /app/dist ./dist
COPY --from=builder /app/package.json ./ COPY --from=builder /app/package.json ./
# Copy assets directory for email templates and logos
COPY --from=builder /app/assets ./assets
# Create logs directory with proper permissions # Create logs directory with proper permissions
RUN mkdir -p logs && chmod 777 logs RUN mkdir -p logs && chmod 777 logs
+8 -7
View File
@@ -28,12 +28,12 @@ JWT_REFRESH_EXPIRATION=7d
# Email Configuration (SMTP) # Email Configuration (SMTP)
# CHANGE THESE: Configure your email provider # CHANGE THESE: Configure your email provider
EMAIL_HOST=smtp.yourmailprovider.com EMAIL_HOST=mail.serpentrace.hu
EMAIL_PORT=587 EMAIL_PORT=465
EMAIL_SECURE=false EMAIL_SECURE=true
EMAIL_USER=your_email@yourdomain.com EMAIL_USER=noreply@serpentrace.hu
EMAIL_PASS=your_email_password EMAIL_PASS=ZUx720ece&Cin&F{
EMAIL_FROM="SerpentRace <noreply@yourdomain.com>" EMAIL_FROM="SerpentRace <noreply@serpentrace.hu>"
# MinIO Object Storage # MinIO Object Storage
MINIO_ENDPOINT=minio MINIO_ENDPOINT=minio
@@ -45,7 +45,8 @@ MINIO_SECRET_KEY=CHANGE_THIS_MINIO_SECRET_KEY_123!
MINIO_BUCKET_NAME=serpentrace-logs MINIO_BUCKET_NAME=serpentrace-logs
# Application Settings # Application Settings
APP_BASE_URL=http://your-domain.com APP_BASE_URL=https://szesnake.ddc.sze.hu
FRONTEND_URL=https://szesnake.ddc.sze.hu
PORT=3000 PORT=3000
# Chat System Limits # Chat System Limits
@@ -24,9 +24,9 @@ if %errorlevel% neq 0 (
exit /b 1 exit /b 1
) )
REM Check if serpentRaceDocker.tar exists REM Check if serpentrace-images.tar exists
if not exist "serpentRaceDocker.tar" ( if not exist "serpentrace-images.tar" (
echo [ERROR] serpentRaceDocker.tar not found! echo [ERROR] serpentrace-images.tar not found!
echo Please ensure the tar file is in the same directory as this script. echo Please ensure the tar file is in the same directory as this script.
pause pause
exit /b 1 exit /b 1
@@ -40,8 +40,8 @@ if not exist ".env.server" (
exit /b 1 exit /b 1
) )
echo [INFO] Loading Docker images from serpentRaceDocker.tar... echo [INFO] Loading Docker images from serpentrace-images.tar...
docker load -i serpentRaceDocker.tar docker load -i serpentrace-images.tar
if %errorlevel% neq 0 ( if %errorlevel% neq 0 (
echo [ERROR] Failed to load Docker images! echo [ERROR] Failed to load Docker images!
pause pause
+5 -5
View File
@@ -20,9 +20,9 @@ if ! command -v docker-compose &> /dev/null; then
exit 1 exit 1
fi fi
# Check if serpentRaceDocker.tar exists # Check if serpentrace-images.tar exists
if [ ! -f "serpentRaceDocker.tar" ]; then if [ ! -f "serpentrace-images.tar" ]; then
echo "[ERROR] serpentRaceDocker.tar not found!" echo "[ERROR] serpentrace-images.tar not found!"
echo "Please ensure the tar file is in the same directory as this script." echo "Please ensure the tar file is in the same directory as this script."
exit 1 exit 1
fi fi
@@ -34,8 +34,8 @@ if [ ! -f ".env.server" ]; then
exit 1 exit 1
fi fi
echo "[INFO] Loading Docker images from serpentRaceDocker.tar..." echo "[INFO] Loading Docker images from serpentrace-images.tar..."
docker load -i serpentRaceDocker.tar docker load -i serpentrace-images.tar
echo "[INFO] Images loaded successfully!" echo "[INFO] Images loaded successfully!"
echo echo
+1 -1
View File
@@ -22,7 +22,7 @@ server {
# API proxy to backend # API proxy to backend
location /api/ { location /api/ {
proxy_pass http://backend:3000/; proxy_pass http://backend:3000;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade'; proxy_set_header Connection 'upgrade';
+153 -209
View File
@@ -1,236 +1,180 @@
-- SerpentRace Database Schema -- This script was generated by the ERD tool in pgAdmin 4.
-- Generated from TypeORM Entity Aggregates -- Please log an issue at https://github.com/pgadmin-org/pgadmin4/issues/new/choose if you find any bugs, including reproduction steps.
-- This file creates the complete database schema without initial data BEGIN;
-- Enable UUID extension -- ===================================================================
-- STEP 1: Enable Required Extensions
-- ===================================================================
CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-- Create Users table -- ===================================================================
CREATE TABLE "Users" ( -- STEP 2: Create Tables
"id" UUID PRIMARY KEY DEFAULT uuid_generate_v4(), -- ===================================================================
"orgid" UUID NULL,
"username" VARCHAR(100) UNIQUE NOT NULL, CREATE TABLE IF NOT EXISTS public."ChatArchives"
"password" VARCHAR(255) NOT NULL, (
"email" VARCHAR(255) UNIQUE NOT NULL, id uuid NOT NULL DEFAULT uuid_generate_v4(),
"fname" VARCHAR(100) NOT NULL, "chatId" uuid NOT NULL,
"lname" VARCHAR(100) NOT NULL, "archivedMessages" json NOT NULL,
"token" VARCHAR(255) NULL, "archivedAt" timestamp without time zone NOT NULL,
"TokenExpires" TIMESTAMP NULL, "createDate" timestamp without time zone NOT NULL DEFAULT now(),
"phone" VARCHAR(20) NULL, "chatType" character varying(50) COLLATE pg_catalog."default" NOT NULL,
"state" INTEGER NOT NULL DEFAULT 0, "chatName" character varying(255) COLLATE pg_catalog."default",
"regdate" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "gameId" uuid,
"updatedate" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, participants uuid[] NOT NULL,
"Orglogindate" TIMESTAMP NULL CONSTRAINT "PK_fe62979fc2061d7afe278d3f14e" PRIMARY KEY (id)
); );
-- Create Organizations table CREATE TABLE IF NOT EXISTS public."Chats"
CREATE TABLE "Organizations" ( (
"id" UUID PRIMARY KEY DEFAULT uuid_generate_v4(), id uuid NOT NULL DEFAULT uuid_generate_v4(),
"name" VARCHAR(255) NOT NULL, type character varying(50) COLLATE pg_catalog."default" NOT NULL DEFAULT 'direct'::character varying,
"contactfname" VARCHAR(100) NOT NULL, name character varying(255) COLLATE pg_catalog."default",
"contactlname" VARCHAR(100) NOT NULL, "gameId" uuid,
"contactphone" VARCHAR(20) NOT NULL, "createdBy" uuid,
"contactemail" VARCHAR(255) NOT NULL, users uuid[] NOT NULL,
"state" INTEGER NOT NULL DEFAULT 0, messages json NOT NULL DEFAULT '[]'::json,
"regdate" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "lastActivity" timestamp without time zone,
"updatedate" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "createDate" timestamp without time zone NOT NULL DEFAULT now(),
"url" VARCHAR(500) NULL, "updateDate" timestamp without time zone NOT NULL DEFAULT now(),
"userinorg" INTEGER NOT NULL DEFAULT 0, state integer NOT NULL DEFAULT 0,
"maxOrganizationalDecks" INTEGER NULL "archiveDate" timestamp without time zone,
CONSTRAINT "PK_64c36c2b8d86a0d5de4cf64de8d" PRIMARY KEY (id)
); );
-- Create Decks table CREATE TABLE IF NOT EXISTS public."Contacts"
CREATE TABLE "Decks" ( (
"id" UUID PRIMARY KEY DEFAULT uuid_generate_v4(), id uuid NOT NULL DEFAULT uuid_generate_v4(),
"name" VARCHAR(255) NOT NULL, name character varying(255) COLLATE pg_catalog."default" NOT NULL,
"type" INTEGER NOT NULL, email character varying(255) COLLATE pg_catalog."default" NOT NULL,
"user_id" UUID NOT NULL, userid uuid,
"creation_date" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, type integer NOT NULL,
"cards" JSONB NOT NULL DEFAULT '[]', txt text COLLATE pg_catalog."default" NOT NULL,
"played_number" INTEGER NOT NULL DEFAULT 0, state integer NOT NULL DEFAULT 0,
"ctype" INTEGER NOT NULL DEFAULT 0, "createDate" timestamp without time zone NOT NULL DEFAULT now(),
"update_date" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "updateDate" timestamp without time zone NOT NULL DEFAULT now(),
"state" INTEGER NOT NULL DEFAULT 0, "adminResponse" text COLLATE pg_catalog."default",
"organization_id" UUID NULL "responseDate" timestamp without time zone,
"respondedBy" uuid,
CONSTRAINT "PK_68782cec65c8eef577c62958273" PRIMARY KEY (id)
); );
-- Create Chats table CREATE TABLE IF NOT EXISTS public."Decks"
CREATE TABLE "Chats" ( (
"id" UUID PRIMARY KEY DEFAULT uuid_generate_v4(), id uuid NOT NULL DEFAULT uuid_generate_v4(),
"type" VARCHAR(50) NOT NULL DEFAULT 'direct', name character varying(255) COLLATE pg_catalog."default" NOT NULL,
"name" VARCHAR(255) NULL, type integer NOT NULL,
"gameId" UUID NULL, user_id uuid NOT NULL,
"createdBy" UUID NULL, creation_date timestamp without time zone NOT NULL DEFAULT now(),
"users" UUID[] NOT NULL, cards json NOT NULL,
"messages" JSONB NOT NULL DEFAULT '[]', played_number integer NOT NULL DEFAULT 0,
"lastActivity" TIMESTAMP NULL, ctype integer NOT NULL DEFAULT 0,
"createDate" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "updateDate" timestamp without time zone NOT NULL DEFAULT now(),
"updateDate" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, state integer NOT NULL DEFAULT 0,
"state" INTEGER NOT NULL DEFAULT 0, organization_id uuid,
"archiveDate" TIMESTAMP NULL CONSTRAINT "PK_001f26cb3ec39c1f25269943473" PRIMARY KEY (id)
); );
-- Create Contacts table CREATE TABLE IF NOT EXISTS public."Games"
CREATE TABLE "Contacts" ( (
"id" UUID PRIMARY KEY DEFAULT uuid_generate_v4(), id uuid NOT NULL DEFAULT uuid_generate_v4(),
"name" VARCHAR(255) NOT NULL, gamecode character varying(10) COLLATE pg_catalog."default" NOT NULL,
"email" VARCHAR(255) NOT NULL, maxplayers integer NOT NULL,
"userid" UUID NULL, logintype integer NOT NULL DEFAULT 0,
"type" INTEGER NOT NULL, boardsize integer NOT NULL DEFAULT 50,
"txt" TEXT NOT NULL, "createdBy" uuid NOT NULL,
"state" INTEGER NOT NULL DEFAULT 0, organizationid uuid,
"createDate" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, decks jsonb NOT NULL DEFAULT '[]'::jsonb,
"updateDate" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, playerids uuid[] NOT NULL DEFAULT '{}'::uuid[],
"adminResponse" TEXT NULL, "winnerId" uuid,
"responseDate" TIMESTAMP NULL, state integer NOT NULL DEFAULT 0,
"respondedBy" UUID NULL "createDate" timestamp without time zone NOT NULL DEFAULT now(),
start_date timestamp without time zone,
"finishDate" timestamp without time zone,
"updateDate" timestamp without time zone NOT NULL DEFAULT now(),
"organizationId" uuid,
CONSTRAINT "PK_1950492f583d31609c5e9fbbe12" PRIMARY KEY (id),
CONSTRAINT "UQ_9d52c646079cbe6f242a85c5c41" UNIQUE (gamecode)
); );
-- Create Games table CREATE TABLE IF NOT EXISTS public."Organizations"
CREATE TABLE "Games" ( (
"id" UUID PRIMARY KEY DEFAULT uuid_generate_v4(), id uuid NOT NULL DEFAULT uuid_generate_v4(),
"gamecode" VARCHAR(10) UNIQUE NOT NULL, name character varying(255) COLLATE pg_catalog."default" NOT NULL,
"maxplayers" INTEGER NOT NULL, contactfname character varying(100) COLLATE pg_catalog."default" NOT NULL,
"logintype" INTEGER NOT NULL DEFAULT 0, contactlname character varying(100) COLLATE pg_catalog."default" NOT NULL,
"state" INTEGER NOT NULL DEFAULT 0, contactphone character varying(20) COLLATE pg_catalog."default" NOT NULL,
"playerids" UUID[] NOT NULL DEFAULT '{}', contactemail character varying(255) COLLATE pg_catalog."default" NOT NULL,
"decks" JSONB NOT NULL DEFAULT '[]', state integer NOT NULL DEFAULT 0,
"boardsize" INTEGER NOT NULL DEFAULT 50, regdate timestamp without time zone NOT NULL DEFAULT now(),
"createDate" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "updateDate" timestamp without time zone NOT NULL DEFAULT now(),
"updateDate" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, url character varying(500) COLLATE pg_catalog."default",
"finishDate" TIMESTAMP NULL, userinorg integer NOT NULL DEFAULT 0,
"winnerid" UUID NULL, "maxOrganizationalDecks" integer,
"createdBy" UUID NOT NULL, CONSTRAINT "PK_e0690a31419f6666194423526f2" PRIMARY KEY (id)
"organizationid" UUID NULL
); );
-- Add Foreign Key Constraints CREATE TABLE IF NOT EXISTS public."Users"
ALTER TABLE "Users" (
ADD CONSTRAINT "FK_Users_Organizations" id uuid NOT NULL DEFAULT uuid_generate_v4(),
FOREIGN KEY ("orgid") REFERENCES "Organizations"("id") ON DELETE SET NULL; orgid uuid,
username character varying(100) COLLATE pg_catalog."default" NOT NULL,
password character varying(255) COLLATE pg_catalog."default" NOT NULL,
email character varying(255) COLLATE pg_catalog."default" NOT NULL,
fname character varying(100) COLLATE pg_catalog."default" NOT NULL,
lname character varying(100) COLLATE pg_catalog."default" NOT NULL,
token character varying(255) COLLATE pg_catalog."default",
"TokenExpires" timestamp without time zone,
phone character varying(20) COLLATE pg_catalog."default",
state integer NOT NULL DEFAULT 0,
regdate timestamp without time zone NOT NULL DEFAULT now(),
"updateDate" timestamp without time zone NOT NULL DEFAULT now(),
"Orglogindate" timestamp without time zone,
CONSTRAINT "PK_16d4f7d636df336db11d87413e3" PRIMARY KEY (id),
CONSTRAINT "UQ_3c3ab3f49a87e6ddb607f3c4945" UNIQUE (email),
CONSTRAINT "UQ_ffc81a3b97dcbf8e320d5106c0d" UNIQUE (username)
);
ALTER TABLE "Decks" CREATE TABLE IF NOT EXISTS public.migrations
ADD CONSTRAINT "FK_Decks_Users" (
FOREIGN KEY ("user_id") REFERENCES "Users"("id") ON DELETE CASCADE; id serial NOT NULL,
"timestamp" bigint NOT NULL,
name character varying COLLATE pg_catalog."default" NOT NULL,
CONSTRAINT "PK_8c82d7f526340ab734260ea46be" PRIMARY KEY (id)
);
ALTER TABLE "Decks" ALTER TABLE IF EXISTS public."Decks"
ADD CONSTRAINT "FK_Decks_Organizations" ADD CONSTRAINT "FK_06ee28f90d68543a03b14aebe13" FOREIGN KEY (organization_id)
FOREIGN KEY ("organization_id") REFERENCES "Organizations"("id") ON DELETE SET NULL; REFERENCES public."Organizations" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION;
ALTER TABLE "Contacts"
ADD CONSTRAINT "FK_Contacts_Users"
FOREIGN KEY ("userid") REFERENCES "Users"("id") ON DELETE SET NULL;
ALTER TABLE "Contacts" ALTER TABLE IF EXISTS public."Decks"
ADD CONSTRAINT "FK_Contacts_RespondedBy" ADD CONSTRAINT "FK_a39059433e29882e1309d3a5e70" FOREIGN KEY (user_id)
FOREIGN KEY ("respondedBy") REFERENCES "Users"("id") ON DELETE SET NULL; REFERENCES public."Users" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION;
ALTER TABLE "Chats"
ADD CONSTRAINT "FK_Chats_CreatedBy"
FOREIGN KEY ("createdBy") REFERENCES "Users"("id") ON DELETE SET NULL;
ALTER TABLE "Chats" ALTER TABLE IF EXISTS public."Games"
ADD CONSTRAINT "FK_Chats_Games" ADD CONSTRAINT "FK_330362bff8b25bb573f31fb4023" FOREIGN KEY ("winnerId")
FOREIGN KEY ("gameId") REFERENCES "Games"("id") ON DELETE SET NULL; REFERENCES public."Users" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION;
ALTER TABLE "Games"
ADD CONSTRAINT "FK_Games_CreatedBy"
FOREIGN KEY ("createdBy") REFERENCES "Users"("id") ON DELETE CASCADE;
ALTER TABLE "Games" ALTER TABLE IF EXISTS public."Games"
ADD CONSTRAINT "FK_Games_Organizations" ADD CONSTRAINT "FK_e3c4e8898fa026a5551aefc4f62" FOREIGN KEY ("organizationId")
FOREIGN KEY ("organizationid") REFERENCES "Organizations"("id") ON DELETE SET NULL; REFERENCES public."Organizations" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION;
ALTER TABLE "Games"
ADD CONSTRAINT "FK_Games_Winner"
FOREIGN KEY ("winnerid") REFERENCES "Users"("id") ON DELETE SET NULL;
-- Create Indexes for Performance ALTER TABLE IF EXISTS public."Games"
CREATE INDEX "IDX_Users_Username" ON "Users" ("username"); ADD CONSTRAINT "FK_f32db60863a8a393b30aa222cd5" FOREIGN KEY ("createdBy")
CREATE INDEX "IDX_Users_Email" ON "Users" ("email"); REFERENCES public."Users" (id) MATCH SIMPLE
CREATE INDEX "IDX_Users_OrgId" ON "Users" ("orgid"); ON UPDATE NO ACTION
CREATE INDEX "IDX_Users_State" ON "Users" ("state"); ON DELETE NO ACTION;
CREATE INDEX "IDX_Organizations_Name" ON "Organizations" ("name");
CREATE INDEX "IDX_Organizations_State" ON "Organizations" ("state");
CREATE INDEX "IDX_Decks_UserId" ON "Decks" ("user_id");
CREATE INDEX "IDX_Decks_Type" ON "Decks" ("type");
CREATE INDEX "IDX_Decks_CType" ON "Decks" ("ctype");
CREATE INDEX "IDX_Decks_State" ON "Decks" ("state");
CREATE INDEX "IDX_Decks_OrganizationId" ON "Decks" ("organization_id");
CREATE INDEX "IDX_Chats_Type" ON "Chats" ("type");
CREATE INDEX "IDX_Chats_State" ON "Chats" ("state");
CREATE INDEX "IDX_Chats_GameId" ON "Chats" ("gameId");
CREATE INDEX "IDX_Chats_CreatedBy" ON "Chats" ("createdBy");
CREATE INDEX "IDX_Contacts_Type" ON "Contacts" ("type");
CREATE INDEX "IDX_Contacts_State" ON "Contacts" ("state");
CREATE INDEX "IDX_Contacts_UserId" ON "Contacts" ("userid");
CREATE INDEX "IDX_Games_GameCode" ON "Games" ("gamecode");
CREATE INDEX "IDX_Games_State" ON "Games" ("state");
CREATE INDEX "IDX_Games_CreatedBy" ON "Games" ("createdBy");
CREATE INDEX "IDX_Games_OrganizationId" ON "Games" ("organizationid");
-- Create update trigger for updatedate columns
CREATE OR REPLACE FUNCTION update_updatedate_column()
RETURNS TRIGGER AS $$
BEGIN
NEW.updatedate = CURRENT_TIMESTAMP;
RETURN NEW;
END; END;
$$ language 'plpgsql';
-- Apply update triggers
CREATE TRIGGER update_users_updatedate
BEFORE UPDATE ON "Users"
FOR EACH ROW EXECUTE FUNCTION update_updatedate_column();
CREATE TRIGGER update_organizations_updatedate
BEFORE UPDATE ON "Organizations"
FOR EACH ROW EXECUTE FUNCTION update_updatedate_column();
CREATE TRIGGER update_decks_updatedate
BEFORE UPDATE ON "Decks"
FOR EACH ROW EXECUTE FUNCTION update_updatedate_column();
CREATE TRIGGER update_chats_updatedate
BEFORE UPDATE ON "Chats"
FOR EACH ROW EXECUTE FUNCTION update_updatedate_column();
CREATE TRIGGER update_contacts_updatedate
BEFORE UPDATE ON "Contacts"
FOR EACH ROW EXECUTE FUNCTION update_updatedate_column();
CREATE TRIGGER update_games_updatedate
BEFORE UPDATE ON "Games"
FOR EACH ROW EXECUTE FUNCTION update_updatedate_column();
-- Comments for documentation
COMMENT ON TABLE "Users" IS 'User accounts with authentication and profile information';
COMMENT ON TABLE "Organizations" IS 'Organizations that can have multiple users and premium features';
COMMENT ON TABLE "Decks" IS 'Card decks for the game, can be public, private, or organizational';
COMMENT ON TABLE "Chats" IS 'Chat system supporting direct messages, groups, and game chats';
COMMENT ON TABLE "Contacts" IS 'Contact form submissions and support tickets';
COMMENT ON TABLE "Games" IS 'Game sessions with players, decks, and game state';
-- Enum value comments
COMMENT ON COLUMN "Users"."state" IS '0=REGISTERED_NOT_VERIFIED, 1=VERIFIED_REGULAR, 2=VERIFIED_PREMIUM, 3=SOFT_DELETE, 4=DEACTIVATED, 5=ADMIN';
COMMENT ON COLUMN "Organizations"."state" IS '0=REGISTERED, 1=ACTIVE, 2=SOFT_DELETE';
COMMENT ON COLUMN "Decks"."type" IS '0=LUCK, 1=JOKER, 2=QUESTION';
COMMENT ON COLUMN "Decks"."ctype" IS '0=PUBLIC, 1=PRIVATE, 2=ORGANIZATION';
COMMENT ON COLUMN "Decks"."state" IS '0=ACTIVE, 1=SOFT_DELETE';
COMMENT ON COLUMN "Chats"."type" IS 'direct, group, game';
COMMENT ON COLUMN "Chats"."state" IS '0=ACTIVE, 1=ARCHIVE, 2=SOFT_DELETE';
COMMENT ON COLUMN "Contacts"."type" IS '0=BUG, 1=PROBLEM, 2=QUESTION, 3=SALES, 4=OTHER';
COMMENT ON COLUMN "Contacts"."state" IS '0=ACTIVE, 1=RESOLVED, 2=SOFT_DELETE';
COMMENT ON COLUMN "Games"."state" IS '0=WAITING, 1=ACTIVE, 2=FINISHED, 3=CANCELLED';
COMMENT ON COLUMN "Games"."logintype" IS '0=PUBLIC, 1=PRIVATE, 2=ORGANIZATION';
-- Grant permissions for application user
-- Note: Replace 'serpentrace_app' with your actual application database user
-- GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO serpentrace_app;
-- GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO serpentrace_app;
-- GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO serpentrace_app;
+26 -67
View File
@@ -8,31 +8,8 @@ services:
restart: unless-stopped restart: unless-stopped
ports: ports:
- "3000:3000" - "3000:3000"
environment: env_file:
- NODE_ENV=production - .env.server
- PORT=3000
- DB_HOST=postgres
- DB_PORT=5432
- DB_NAME=serpentrace
- DB_USERNAME=postgres
- DB_PASSWORD=${POSTGRES_PASSWORD}
- REDIS_URL=redis://redis:6379
- REDIS_HOST=redis
- REDIS_PORT=6379
- JWT_SECRET=${JWT_SECRET}
- JWT_EXPIRATION=${JWT_EXPIRATION:-24h}
- JWT_REFRESH_EXPIRATION=${JWT_REFRESH_EXPIRATION:-7d}
- MINIO_ENDPOINT=minio
- MINIO_PORT=9000
- MINIO_ACCESS_KEY=${MINIO_ACCESS_KEY}
- MINIO_SECRET_KEY=${MINIO_SECRET_KEY}
- MINIO_USE_SSL=false
- EMAIL_HOST=${EMAIL_HOST}
- EMAIL_PORT=${EMAIL_PORT}
- EMAIL_SECURE=${EMAIL_SECURE}
- EMAIL_USER=${EMAIL_USER}
- EMAIL_PASS=${EMAIL_PASS}
- EMAIL_FROM=${EMAIL_FROM}
volumes: volumes:
- backend_logs:/app/logs - backend_logs:/app/logs
depends_on: depends_on:
@@ -44,12 +21,7 @@ services:
condition: service_healthy condition: service_healthy
networks: networks:
- serpentrace-network - serpentrace-network
healthcheck: tty: true
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# Frontend service using pre-built image # Frontend service using pre-built image
frontend: frontend:
@@ -57,8 +29,10 @@ services:
container_name: serpentrace-frontend container_name: serpentrace-frontend
restart: unless-stopped restart: unless-stopped
ports: ports:
- "80:80" - "8080:80"
- "443:443" - "443:443"
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
depends_on: depends_on:
- backend - backend
networks: networks:
@@ -79,7 +53,7 @@ services:
environment: environment:
POSTGRES_DB: serpentrace POSTGRES_DB: serpentrace
POSTGRES_USER: postgres POSTGRES_USER: postgres
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_PASSWORD: postgres
POSTGRES_INITDB_ARGS: "--encoding=UTF-8" POSTGRES_INITDB_ARGS: "--encoding=UTF-8"
volumes: volumes:
- postgres_data:/var/lib/postgresql/data - postgres_data:/var/lib/postgresql/data
@@ -101,7 +75,7 @@ services:
- "6379:6379" - "6379:6379"
volumes: volumes:
- redis_data:/data - redis_data:/data
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD} command: redis-server --appendonly yes
networks: networks:
- serpentrace-network - serpentrace-network
healthcheck: healthcheck:
@@ -119,8 +93,8 @@ services:
- "9000:9000" - "9000:9000"
- "9001:9001" - "9001:9001"
environment: environment:
MINIO_ROOT_USER: ${MINIO_ACCESS_KEY} MINIO_ROOT_USER: serpentrace
MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY} MINIO_ROOT_PASSWORD: serpentrace123!
volumes: volumes:
- minio_data:/data - minio_data:/data
command: server /data --console-address ":9001" command: server /data --console-address ":9001"
@@ -132,45 +106,32 @@ services:
timeout: 5s timeout: 5s
retries: 5 retries: 5
# Adminer Database Viewer
adminer:
image: adminer:latest
container_name: serpentrace-adminer
restart: unless-stopped
ports:
- "8083:8080" # Access via http://<server-ip>:8083
depends_on:
- postgres
networks:
- serpentrace-network
# Redis Commander for internal administration # Redis Commander
redis-commander: redis-commander:
image: rediscommander/redis-commander:latest image: rediscommander/redis-commander:latest
container_name: serpentrace-redis-commander-dev container_name: serpentrace-redis-commander
restart: unless-stopped restart: unless-stopped
ports: ports:
- "8081:8081" - "8082:8081" # Access via http://<server-ip>:8082
environment: environment:
- REDIS_HOSTS=local:redis:6379 REDIS_HOSTS: local:serpentrace-redis:6379
depends_on: depends_on:
redis: - redis
condition: service_healthy
networks: networks:
- serpentrace-network - serpentrace-network
# Database administration tool for internal administration
pgadmin:
image: dpage/pgadmin4:latest
container_name: serpentrace-pgadmin
restart: unless-stopped
ports:
- "5050:80"
environment:
PGADMIN_DEFAULT_EMAIL: admin@serpentrace.dev
PGADMIN_DEFAULT_PASSWORD: admin
PGADMIN_CONFIG_SERVER_MODE: 'False'
PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED: 'False'
PGADMIN_CONFIG_WTF_CSRF_ENABLED: 'False'
volumes:
- pgadmin_data:/var/lib/pgadmin
- ./deployment/pgadmin_servers_deployment.json:/pgadmin4/servers.json:ro
depends_on:
postgres:
condition: service_healthy
networks:
- serpentrace-network
volumes: volumes:
postgres_data: postgres_data:
driver: local driver: local
@@ -180,8 +141,6 @@ volumes:
driver: local driver: local
backend_logs: backend_logs:
driver: local driver: local
pgadmin_data:
driver: local
networks: networks:
serpentrace-network: serpentrace-network:
+38 -5
View File
@@ -22,7 +22,7 @@ server {
# API proxy to backend # API proxy to backend
location /api/ { location /api/ {
proxy_pass http://backend:3000/; proxy_pass http://backend:3000;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade'; proxy_set_header Connection 'upgrade';
@@ -45,10 +45,43 @@ server {
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $scheme;
} }
# Static assets caching # Adminer Database Viewer proxy
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { location /adminer/ {
expires 1y; proxy_pass http://adminer:8080/;
add_header Cache-Control "public, immutable"; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Redis Commander proxy
location /redis/ {
proxy_pass http://redis-commander:8081/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect http://redis-commander:8081/ /redis/;
proxy_cache_bypass $http_upgrade;
}
# MinIO Console proxy
location /minio/ {
proxy_pass http://minio:9001/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect http://minio:9001/ /minio/;
sub_filter '<base href="/"' '<base href="/minio/"';
sub_filter_types text/html;
proxy_cache_bypass $http_upgrade;
} }
# Health check endpoint # Health check endpoint
+1 -1
View File
@@ -22,7 +22,7 @@ server {
# API proxy to backend # API proxy to backend
location /api/ { location /api/ {
proxy_pass http://backend:3000/; proxy_pass http://backend:3000;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade'; proxy_set_header Connection 'upgrade';
+103
View File
@@ -0,0 +1,103 @@
@echo off
REM SerpentRace Production Deployment Script
REM This script loads Docker images and starts the production environment
setlocal EnableDelayedExpansion
echo ===============================================
echo SerpentRace Production Deployment
echo ===============================================
echo.
REM Check if Docker is installed
where docker >nul 2>nul
if %errorlevel% neq 0 (
echo [ERROR] Docker is not installed. Please install Docker first.
pause
exit /b 1
)
where docker-compose >nul 2>nul
if %errorlevel% neq 0 (
echo [ERROR] Docker Compose is not installed. Please install Docker Compose first.
pause
exit /b 1
)
REM Check if serpentrace-images.tar exists
if not exist "serpentrace-images.tar" (
echo [ERROR] serpentrace-images.tar not found!
echo Please ensure the tar file is in the same directory as this script.
pause
exit /b 1
)
REM Check if environment file exists
if not exist ".env.server" (
echo [ERROR] .env.server file not found!
echo Please ensure the environment file is configured.
pause
exit /b 1
)
echo [INFO] Loading Docker images from serpentrace-images.tar...
docker load -i serpentrace-images.tar
if %errorlevel% neq 0 (
echo [ERROR] Failed to load Docker images!
pause
exit /b 1
)
echo [INFO] Images loaded successfully!
echo.
REM Show loaded images
echo [INFO] Loaded images:
docker images | findstr serpentrace
docker images | findstr postgres
docker images | findstr redis
docker images | findstr minio
echo.
echo [WARNING] Before starting the services, please review and update .env.server:
echo - Change all placeholder passwords
echo - Configure email settings
echo - Update domain names
echo - Set strong JWT secret
echo.
echo Press any key to continue with deployment or Ctrl+C to exit...
pause >nul
echo [INFO] Starting production services...
docker-compose -f docker-compose.deploy.yml --env-file .env.server up -d
if %errorlevel% neq 0 (
echo [ERROR] Failed to start services!
pause
exit /b 1
)
echo.
echo ===============================================
echo Deployment Complete!
echo ===============================================
echo.
echo Services are starting up. Please wait a few moments for all services to be ready.
echo.
echo Available services:
echo - Frontend: http://localhost (or your domain)
echo - Backend API: http://localhost:3000
echo - MinIO Console: http://localhost:9001
echo.
echo To check service status: docker-compose -f docker-compose.deploy.yml ps
echo To view logs: docker-compose -f docker-compose.deploy.yml logs -f [service_name]
echo To stop services: docker-compose -f docker-compose.deploy.yml down
echo.
echo IMPORTANT SECURITY NOTES:
echo 1. Change all default passwords in .env.server
echo 2. Configure firewall rules for your server
echo 3. Set up SSL/TLS certificates for HTTPS
echo 4. Configure regular backups
echo 5. Monitor logs and system resources
echo.
pause
+81
View File
@@ -0,0 +1,81 @@
#!/bin/bash
# SerpentRace Production Deployment Script for Linux
# This script loads Docker images and starts the production environment
set -e
echo "==============================================="
echo "SerpentRace Production Deployment"
echo "==============================================="
echo
# Check if Docker is installed
if ! command -v docker &> /dev/null; then
echo "[ERROR] Docker is not installed. Please install Docker first."
exit 1
fi
if ! command -v docker-compose &> /dev/null; then
echo "[ERROR] Docker Compose is not installed. Please install Docker Compose first."
exit 1
fi
# Check if serpentrace-images.tar exists
if [ ! -f "serpentrace-images.tar" ]; then
echo "[ERROR] serpentrace-images.tar not found!"
echo "Please ensure the tar file is in the same directory as this script."
exit 1
fi
# Check if environment file exists
if [ ! -f ".env.server" ]; then
echo "[ERROR] .env.server file not found!"
echo "Please ensure the environment file is configured."
exit 1
fi
echo "[INFO] Loading Docker images from serpentrace-images.tar..."
docker load -i serpentrace-images.tar
echo "[INFO] Images loaded successfully!"
echo
# Show loaded images
echo "[INFO] Loaded images:"
docker images | grep -E "(serpentrace|postgres|redis|minio)"
echo
echo "[WARNING] Before starting the services, please review and update .env.server:"
echo " - Change all placeholder passwords"
echo " - Configure email settings"
echo " - Update domain names"
echo " - Set strong JWT secret"
echo
read -p "Press Enter to continue with deployment or Ctrl+C to exit..."
echo "[INFO] Starting production services..."
docker-compose -f docker-compose.deploy.yml --env-file .env.server up -d
echo
echo "==============================================="
echo "Deployment Complete!"
echo "==============================================="
echo
echo "Services are starting up. Please wait a few moments for all services to be ready."
echo
echo "Available services:"
echo " - Frontend: http://localhost (or your domain)"
echo " - Backend API: http://localhost:3000"
echo " - MinIO Console: http://localhost:9001"
echo
echo "To check service status: docker-compose -f docker-compose.deploy.yml ps"
echo "To view logs: docker-compose -f docker-compose.deploy.yml logs -f [service_name]"
echo "To stop services: docker-compose -f docker-compose.deploy.yml down"
echo
echo "IMPORTANT SECURITY NOTES:"
echo "1. Change all default passwords in .env.server"
echo "2. Configure firewall rules for your server"
echo "3. Set up SSL/TLS certificates for HTTPS"
echo "4. Configure regular backups"
echo "5. Monitor logs and system resources"
echo
+60
View File
@@ -0,0 +1,60 @@
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html index.htm;
# Enable gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json;
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
# Handle client routing
location / {
try_files $uri $uri/ /index.html;
}
# API proxy to backend
location /api/ {
proxy_pass http://backend:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
}
# WebSocket support
location /socket.io/ {
proxy_pass http://backend:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Static assets caching
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# Health check endpoint
location /health {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
}
}
+180
View File
@@ -0,0 +1,180 @@
-- This script was generated by the ERD tool in pgAdmin 4.
-- Please log an issue at https://github.com/pgadmin-org/pgadmin4/issues/new/choose if you find any bugs, including reproduction steps.
BEGIN;
-- ===================================================================
-- STEP 1: Enable Required Extensions
-- ===================================================================
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-- ===================================================================
-- STEP 2: Create Tables
-- ===================================================================
CREATE TABLE IF NOT EXISTS public."ChatArchives"
(
id uuid NOT NULL DEFAULT uuid_generate_v4(),
"chatId" uuid NOT NULL,
"archivedMessages" json NOT NULL,
"archivedAt" timestamp without time zone NOT NULL,
"createDate" timestamp without time zone NOT NULL DEFAULT now(),
"chatType" character varying(50) COLLATE pg_catalog."default" NOT NULL,
"chatName" character varying(255) COLLATE pg_catalog."default",
"gameId" uuid,
participants uuid[] NOT NULL,
CONSTRAINT "PK_fe62979fc2061d7afe278d3f14e" PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS public."Chats"
(
id uuid NOT NULL DEFAULT uuid_generate_v4(),
type character varying(50) COLLATE pg_catalog."default" NOT NULL DEFAULT 'direct'::character varying,
name character varying(255) COLLATE pg_catalog."default",
"gameId" uuid,
"createdBy" uuid,
users uuid[] NOT NULL,
messages json NOT NULL DEFAULT '[]'::json,
"lastActivity" timestamp without time zone,
"createDate" timestamp without time zone NOT NULL DEFAULT now(),
"updateDate" timestamp without time zone NOT NULL DEFAULT now(),
state integer NOT NULL DEFAULT 0,
"archiveDate" timestamp without time zone,
CONSTRAINT "PK_64c36c2b8d86a0d5de4cf64de8d" PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS public."Contacts"
(
id uuid NOT NULL DEFAULT uuid_generate_v4(),
name character varying(255) COLLATE pg_catalog."default" NOT NULL,
email character varying(255) COLLATE pg_catalog."default" NOT NULL,
userid uuid,
type integer NOT NULL,
txt text COLLATE pg_catalog."default" NOT NULL,
state integer NOT NULL DEFAULT 0,
"createDate" timestamp without time zone NOT NULL DEFAULT now(),
"updateDate" timestamp without time zone NOT NULL DEFAULT now(),
"adminResponse" text COLLATE pg_catalog."default",
"responseDate" timestamp without time zone,
"respondedBy" uuid,
CONSTRAINT "PK_68782cec65c8eef577c62958273" PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS public."Decks"
(
id uuid NOT NULL DEFAULT uuid_generate_v4(),
name character varying(255) COLLATE pg_catalog."default" NOT NULL,
type integer NOT NULL,
user_id uuid NOT NULL,
creation_date timestamp without time zone NOT NULL DEFAULT now(),
cards json NOT NULL,
played_number integer NOT NULL DEFAULT 0,
ctype integer NOT NULL DEFAULT 0,
"updateDate" timestamp without time zone NOT NULL DEFAULT now(),
state integer NOT NULL DEFAULT 0,
organization_id uuid,
CONSTRAINT "PK_001f26cb3ec39c1f25269943473" PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS public."Games"
(
id uuid NOT NULL DEFAULT uuid_generate_v4(),
gamecode character varying(10) COLLATE pg_catalog."default" NOT NULL,
maxplayers integer NOT NULL,
logintype integer NOT NULL DEFAULT 0,
boardsize integer NOT NULL DEFAULT 50,
"createdBy" uuid NOT NULL,
organizationid uuid,
decks jsonb NOT NULL DEFAULT '[]'::jsonb,
playerids uuid[] NOT NULL DEFAULT '{}'::uuid[],
"winnerId" uuid,
state integer NOT NULL DEFAULT 0,
"createDate" timestamp without time zone NOT NULL DEFAULT now(),
start_date timestamp without time zone,
"finishDate" timestamp without time zone,
"updateDate" timestamp without time zone NOT NULL DEFAULT now(),
"organizationId" uuid,
CONSTRAINT "PK_1950492f583d31609c5e9fbbe12" PRIMARY KEY (id),
CONSTRAINT "UQ_9d52c646079cbe6f242a85c5c41" UNIQUE (gamecode)
);
CREATE TABLE IF NOT EXISTS public."Organizations"
(
id uuid NOT NULL DEFAULT uuid_generate_v4(),
name character varying(255) COLLATE pg_catalog."default" NOT NULL,
contactfname character varying(100) COLLATE pg_catalog."default" NOT NULL,
contactlname character varying(100) COLLATE pg_catalog."default" NOT NULL,
contactphone character varying(20) COLLATE pg_catalog."default" NOT NULL,
contactemail character varying(255) COLLATE pg_catalog."default" NOT NULL,
state integer NOT NULL DEFAULT 0,
regdate timestamp without time zone NOT NULL DEFAULT now(),
"updateDate" timestamp without time zone NOT NULL DEFAULT now(),
url character varying(500) COLLATE pg_catalog."default",
userinorg integer NOT NULL DEFAULT 0,
"maxOrganizationalDecks" integer,
CONSTRAINT "PK_e0690a31419f6666194423526f2" PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS public."Users"
(
id uuid NOT NULL DEFAULT uuid_generate_v4(),
orgid uuid,
username character varying(100) COLLATE pg_catalog."default" NOT NULL,
password character varying(255) COLLATE pg_catalog."default" NOT NULL,
email character varying(255) COLLATE pg_catalog."default" NOT NULL,
fname character varying(100) COLLATE pg_catalog."default" NOT NULL,
lname character varying(100) COLLATE pg_catalog."default" NOT NULL,
token character varying(255) COLLATE pg_catalog."default",
"TokenExpires" timestamp without time zone,
phone character varying(20) COLLATE pg_catalog."default",
state integer NOT NULL DEFAULT 0,
regdate timestamp without time zone NOT NULL DEFAULT now(),
"updateDate" timestamp without time zone NOT NULL DEFAULT now(),
"Orglogindate" timestamp without time zone,
CONSTRAINT "PK_16d4f7d636df336db11d87413e3" PRIMARY KEY (id),
CONSTRAINT "UQ_3c3ab3f49a87e6ddb607f3c4945" UNIQUE (email),
CONSTRAINT "UQ_ffc81a3b97dcbf8e320d5106c0d" UNIQUE (username)
);
CREATE TABLE IF NOT EXISTS public.migrations
(
id serial NOT NULL,
"timestamp" bigint NOT NULL,
name character varying COLLATE pg_catalog."default" NOT NULL,
CONSTRAINT "PK_8c82d7f526340ab734260ea46be" PRIMARY KEY (id)
);
ALTER TABLE IF EXISTS public."Decks"
ADD CONSTRAINT "FK_06ee28f90d68543a03b14aebe13" FOREIGN KEY (organization_id)
REFERENCES public."Organizations" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION;
ALTER TABLE IF EXISTS public."Decks"
ADD CONSTRAINT "FK_a39059433e29882e1309d3a5e70" FOREIGN KEY (user_id)
REFERENCES public."Users" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION;
ALTER TABLE IF EXISTS public."Games"
ADD CONSTRAINT "FK_330362bff8b25bb573f31fb4023" FOREIGN KEY ("winnerId")
REFERENCES public."Users" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION;
ALTER TABLE IF EXISTS public."Games"
ADD CONSTRAINT "FK_e3c4e8898fa026a5551aefc4f62" FOREIGN KEY ("organizationId")
REFERENCES public."Organizations" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION;
ALTER TABLE IF EXISTS public."Games"
ADD CONSTRAINT "FK_f32db60863a8a393b30aa222cd5" FOREIGN KEY ("createdBy")
REFERENCES public."Users" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION;
END;