Spring JPA – Element collection of enums not mapping to table correctly : column “…” of relation “…” does not exist

Solution for Spring JPA – Element collection of enums not mapping to table correctly : column “…” of relation “…” does not exist
is Given Below:

I have this account entity:

@Entity
@Table("account")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class Account {

@Id
private Long id;

private String username;

private String email;

private String profilePicture;

private boolean verified;

@Enumerated(EnumType.STRING)
private Status status;

@ElementCollection(targetClass = Role.class, fetch = FetchType.EAGER)
@Enumerated(value = EnumType.STRING)
@CollectionTable(name = "account_roles", joinColumns = @JoinColumn(name = "account_id", referencedColumnName = "id"))
@Column(name = "role")
private Set<Role> roles;

public Account(String username, String email, String profilePicture, boolean verified, Status status, Set<Role> roles) {
    this.username = username;
    this.email = email;
    this.profilePicture = profilePicture;
    this.verified = verified;
    this.status = status;
    this.roles = roles;
}
}

The problem I’m having is with the roles field. For some reason, it’s not being mapped correctly with the account_roles table. I’ve tried looking into similar questions/errors that others have encountered around this topic, but nothing seems to work.

See below the schema.sql and also the error output.
If anyone is able to give any suggestions of what I might be doing wrong or need to fix please let me know. Thanks.

CREATE TYPE role as ENUM (
    'USER', 'SUPPORT', 'ADMIN', 'DEVELOPER'
    );

    CREATE TABLE account (
    id SERIAL PRIMARY KEY,
    username VARCHAR (15) UNIQUE NOT NULL,
    email VARCHAR (50) UNIQUE NOT NULL,
    profile_picture VARCHAR(50) NOT NULL,
    verified BOOLEAN DEFAULT FALSE,
    status status NOT NULL DEFAULT 'ACTIVE'
    );

    CREATE TABLE account_roles (
  account_id int NOT NULL,
  role role NOT NULL,
  UNIQUE (account_id, role),
  CONSTRAINT fk_account
      FOREIGN KEY (account_id)
          REFERENCES account(id)
          ON DELETE CASCADE
);

Error:

Caused by: org.springframework.r2dbc.BadSqlGrammarException: executeMany; bad SQL grammar [INSERT INTO account (username, email, profile_picture, verified, status, roles) VALUES ($1, $2, $3, $4, $5, $6)]; nested exception is io.r2dbc.postgresql.ExceptionFactory$PostgresqlBadGrammarException: [42703] column "roles" of relation "account" does not exist

Caused by: io.r2dbc.postgresql.ExceptionFactory$PostgresqlBadGrammarException: column "roles" of relation "account" does not exist