I am new at Postgres. I run the following script via flyway migration:
V1.0__Create_Service_Users.sql
DO
$do$
BEGIN
IF NOT EXISTS(SELECT FROM pg_catalog.pg_roles WHERE rolname = '${MYSERVICE_USERNAME}') THEN
create role ${MYSERVICE_USERNAME} WITH LOGIN NOSUPERUSER NOINHERIT NOCREATEDB NOCREATEROLE NOREPLICATION PASSWORD '${MYSERVICE_PASSWORD}';
END IF;
END
$do$
V1.1__Create_Schema.sql
create schema if not exists ${SCHEMA_PREFIX};
V1.2__Grant_Permissions_To_Users.sql
grant usage on all sequences in schema ${SCHEMA_PREFIX} to ${MYSERVICE_USERNAME};
alter default privileges in schema ${SCHEMA_PREFIX} grant SELECT, INSERT, UPDATE, DELETE on tables to ${MYSERVICE_USERNAME};
and finally: V2.1__Create_Images.Table.sql
CREATE TABLE ${SCHEMA_PREFIX}.images
(
id SERIAL primary key,
name varchar(250) NOT NULL,
link varchar(250) NOT NULL,
width int NOT NULL,
height int NOT NULL,
unique (name, link)
);
When I attempt to run application, it produces this error: relation "images" does not exist Here is also the database model:
@Entity
@Table(name = "images")
@EntityListeners(AuditingEntityListener.class)
public class ImagesDBO implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
private Long id;
@Column(name = "name", nullable = false)
private String name;
@Column(name = "link", nullable = false)
private String link;
@Column(name = "width", nullable = false)
private Integer width;
@Column(name = "height", nullable = false)
private Integer height;
In all the examples I can find where someone gets an error stating the relation does not exist, it's because they use uppercase letters in their table name. My table name does not have uppercase letters. I am kind stuck and cannot figure out why the table does not exist! can anybody help me please? Thank you.
that error is provide by hibernates or flyway please ?
Did you try to specify schema with @Table
:
Example :
@Entity
@Table(name = "author", schema = "bookstore")
public class ImagesDBO { ... }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.