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,
    "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,
    "org_email" 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_email" TEXT 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_email" 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_email" TEXT NOT NULL,
    "amount" NUMERIC,
    "payment_method" TEXT,
    "transaction_id" TEXT,
    "paid_to_email" 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,
    "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
);
