CREATE TABLE "actions_ref" (
    "id" BIGSERIAL PRIMARY KEY,
    "appCode" TEXT,
    "actionCode" TEXT,
    "actionName" TEXT,
    "validFrom" DATE,
    "validTo" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "crud_config_info" (
    "id" BIGSERIAL PRIMARY KEY,
    "endPtNum" NUMERIC,
    "opsTypeName" TEXT,
    "sqlQueryText" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "status" TEXT,
    "version" NUMERIC,
    "deletedAt" DATE,
    "createdAt" DATE,
    "updatedAt" DATE
);

CREATE TABLE "policies_ref" (
    "id" BIGSERIAL PRIMARY KEY,
    "appCode" TEXT,
    "roleCode" TEXT,
    "resourceCode" TEXT,
    "actionCode" TEXT,
    "canAllow" BOOLEAN,
    "priority" NUMERIC,
    "validFrom" DATE,
    "validTo" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "resources_ref" (
    "id" BIGSERIAL PRIMARY KEY,
    "appCode" TEXT,
    "resourceCode" TEXT,
    "resourceName" TEXT,
    "validFrom" DATE,
    "validTo" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "rules_ref" (
    "id" BIGSERIAL PRIMARY KEY,
    "ruleCode" TEXT,
    "ruleName" TEXT,
    "ruleType" TEXT,
    "ruleDesc" TEXT,
    "ruleText" TEXT,
    "validFrom" DATE,
    "validTo" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "rules_details_ref" (
    "id" BIGSERIAL PRIMARY KEY,
    "ruleCode" TEXT,
    "ruleAttrName" TEXT,
    "ruleAttrText" TEXT,
    "validFrom" DATE,
    "validTo" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);
CREATE TABLE "users" (
    "id" BIGSERIAL PRIMARY KEY NOT NULL,
    "email" TEXT UNIQUE NOT NULL,
    "password" TEXT,
    "userTypeCode" TEXT,
    "name" TEXT,
    "phoneNumber" TEXT,
    "primaryRole" TEXT,
    "resetCode" TEXT,                
    "resetCodeExpires" TIMESTAMP, 
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "user_type" (
    "id" BIGSERIAL PRIMARY KEY NOT NULL,
    "userTypeCode" TEXT UNIQUE NOT NULL,
    "userTypeName" TEXT,
    "userTypeDesc" TEXT,
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "user_additional_details" (
    "id" BIGSERIAL PRIMARY KEY NOT NULL,
    "user_id" NUMERIC NOT NULL,
    "addlDataType" TEXT,
    "addlDataName" TEXT,
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "theatres" (
    "id" BIGSERIAL PRIMARY KEY,
    "theatre_name" TEXT,
    "rows" NUMERIC,
    "columns" NUMERIC,
    "address" TEXT,
    "city" TEXT,
    "images" JSON,
    "total_seats" NUMERIC,
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "theatre_additional_details" (
    "id" BIGSERIAL PRIMARY KEY NOT NULL,
    "theatre_id" NUMERIC NOT NULL,
    "addlDataType" TEXT,
    "addlDataName" TEXT,
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "events" (
    "id" BIGSERIAL PRIMARY KEY,
    "organizer_id" TEXT NOT NULL,
    "event_name" TEXT,
    "start_date" DATE,
    "end_date" DATE,
    "theatre_id" NUMERIC NOT NULL,
    "event_time" TIME,
    "chief_guests" TEXT,
    "description" TEXT,
    "images" JSON,
    "categories" TEXT,
    "age_restriction" NUMERIC,
    "purchase_limit" NUMERIC,
    "cast" TEXT,
    "max_seating" NUMERIC,
    "event_type" TEXT,
    "promoted" TEXT,
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "events_additional_details" (
    "id" BIGSERIAL PRIMARY KEY NOT NULL,
    "events_id" NUMERIC NOT NULL,
    "addlDataType" TEXT,
    "addlDataName" TEXT,
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "event_categories" (
    "id" BIGSERIAL PRIMARY KEY,
    "category_name" TEXT,
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "time_slots" (
    "id" BIGSERIAL PRIMARY KEY,
    "event_id" NUMERIC NOT NULL,
    "start_time" DATE,
    "end_time" DATE,
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "ticket_pricing" (
    "id" BIGSERIAL PRIMARY KEY,
    "event_id" NUMERIC NOT NULL,
    "time_slot_id" NUMERIC,
    "ticket_type" TEXT,
    "price" NUMERIC,
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "tickets" (
    "id" BIGSERIAL PRIMARY KEY,
    "event_id" NUMERIC NOT NULL,
    "ticket_type" TEXT,
    "price" NUMERIC,
    "seat_number" TEXT,
    "qr_code" TEXT,
    "buyer_id" NUMERIC NOT NULL,
    "booking_date" DATE,
    "payment_status" TEXT,
    "rescheduled_at" DATE,
    "scanned" DATE,
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "reviews" (
    "id" BIGSERIAL PRIMARY KEY,
    "event_id" NUMERIC NOT NULL,
    "buyer_id" TEXT NOT NULL,
    "rating" NUMERIC,
    "comment" TEXT,
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "seats" (
    "id" BIGSERIAL PRIMARY KEY,
    "event_id" NUMERIC NOT NULL,
    "seat_number" TEXT,
    "row" TEXT,
    "column" TEXT,
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "payouts" (
    "id" BIGSERIAL PRIMARY KEY,
    "payee_id" TEXT NOT NULL,
    "amount" NUMERIC,
    "payment_method" TEXT,
    "transaction_id" TEXT,
    "paid_to_id" TEXT,
    "payout_date" DATE,
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "refunds" (
    "id" BIGSERIAL PRIMARY KEY,
    "ticket_id" NUMERIC NOT NULL,
    "refund_amount" NUMERIC,
    "refund_percentage" NUMERIC NOT NULL,
    "refund_reason" TEXT NOT NULL,
    "refund_date" DATE,
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "push_notification" (
    "id" BIGSERIAL PRIMARY KEY,
    "user_id" NUMERIC NOT NULL,
    "endpoint" TEXT NOT NULL,
    "p256dh" TEXT,
    "auth" TEXT,
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);


CREATE TABLE "promotions" (
    "id" BIGSERIAL PRIMARY KEY,
    "event_id" NUMERIC NOT NULL,              
    "start_date" DATE,              
    "end_date" DATE,                
    "location" TEXT,                
    "type" TEXT,                    
    "description" TEXT,             
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "event_episodes" (
    "id" BIGSERIAL PRIMARY KEY,
    "event_id" NUMERIC NOT NULL,
    "episode_name" TEXT,       
    "episode_description" TEXT,
    "episode_start_date" DATE, 
    "episode_end_date" DATE,   
    "episode_location" TEXT,   
    "episode_type" TEXT,       
    "images" JSON,
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "cast_members" (
    "id" BIGSERIAL PRIMARY KEY,
    "event_id" NUMERIC NOT NULL,      
    "cast_name" TEXT,          
    "role" TEXT,                      
    "images" JSON,                    
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);

CREATE TABLE "user_watchlist" (
    "id" BIGSERIAL PRIMARY KEY,
    "user_id" NUMERIC NOT NULL,                  
    "event_id" NUMERIC NOT NULL,     
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC                           
);

CREATE TABLE "event_analytics" (
    "id" BIGSERIAL PRIMARY KEY,
    "event_id" NUMERIC NOT NULL,                  
    "views" NUMERIC,                    
    "ticket_sales" NUMERIC,             
    "engagement_rate" NUMERIC,                    
    "promotion_views" NUMERIC,          
    "promotion_sales" NUMERIC,          
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC 
);

CREATE TABLE "locations" (
    "id" BIGSERIAL PRIMARY KEY NOT NULL,
    "name" TEXT,
    "code" TEXT,
    "images" TEXT[],
    "status" TEXT,
    "validFrom" DATE,
    "validTill" DATE,
    "createdAt" DATE,
    "updatedAt" DATE,
    "createdBy" TEXT,
    "modifiedBy" TEXT,
    "deletedAt" DATE,
    "version" NUMERIC
);


