You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DIP/EXECUTE_ENUM_FIX.md

2.3 KiB

ENUM Type Fix - Execution Instructions

Problem

The database has PostgreSQL ENUM types, but Hibernate is configured to use VARCHAR with CHECK constraints. This causes the error:

ERROR: column "contract_nature" is of type ted.contract_nature but expression is of type character varying

Solution

Execute the fix-enum-types-comprehensive.sql script on the remote database.

Execution Methods

psql -h 94.130.218.54 -p 5432 -U postgres -d Sales -f fix-enum-types-comprehensive.sql

When prompted, enter password: PDmXRx0Rbk9OFOn9qO5Gm/mPCfqW8zwbZ+/YIU1lySc=

Option 2: Using psql with inline password (Windows PowerShell)

$env:PGPASSWORD="PDmXRx0Rbk9OFOn9qO5Gm/mPCfqW8zwbZ+/YIU1lySc="
psql -h 94.130.218.54 -p 5432 -U postgres -d Sales -f fix-enum-types-comprehensive.sql

Option 3: Copy-paste into database client

If you're using DBeaver, pgAdmin, or another GUI tool:

  1. Connect to:

    • Host: 94.130.218.54
    • Port: 5432
    • Database: Sales
    • Username: postgres
    • Password: PDmXRx0Rbk9OFOn9qO5Gm/mPCfqW8zwbZ+/YIU1lySc=
  2. Open fix-enum-types-comprehensive.sql in the query editor

  3. Execute the entire script

What the script does

  1. Converts ENUM columns to VARCHAR(50) while preserving existing data
  2. Drops the old ENUM types
  3. Adds CHECK constraints for data validation
  4. Updates the search function to use VARCHAR parameters
  5. Shows verification query at the end

Verification

After execution, you should see:

status                                       | column_name           | data_type         | character_maximum_length
---------------------------------------------|-----------------------|-------------------|--------------------------
ENUM types successfully converted to VARCHAR!| contract_nature       | character varying | 50
ENUM types successfully converted to VARCHAR!| notice_type           | character varying | 50
ENUM types successfully converted to VARCHAR!| procedure_type        | character varying | 50
ENUM types successfully converted to VARCHAR!| vectorization_status  | character varying | 50

After execution

Restart your Spring Boot application. The error should be resolved and the application will be able to insert data into the database.