I've been struggling with this issue for a good while now and I couldn't find any solution for this so I need your help. I'm using postgres image within Docker container and Java Spring. So basically my database in the docker container. So I created this V1 migration with flyway and wrote this SQL code to create a table
CREATE TABLE customer(
id BIGSERIAL PRIMARY KEY,
name TEXT NOT NULL,
email TEXT NOT NULL,
age INT NOT NULL
)
And I thought it's supposed to create this exact table in my docker container.
So I get inside of docker container and i type \d customer
i see a different database like this
Have a look. The table is different from what i created
As you can see it has "varchar" instead of TEXT, and it also has constraints that i didn't specify when i was creating the table.
I thought it might be because of the entity i have (the code snippet below). But i strongly doubt it's because of that
@Entity
@Data
public class Customer {
@Id
@GeneratedValue(
strategy = GenerationType.SEQUENCE,
generator = "customer_id_sequence"
)
@SequenceGenerator(
name = "customer_id_sequence",
sequenceName = "customer_id_sequence")
private Integer id;
@Column(nullable = false, name = "name")
private String name;
@Column(nullable = false, name = "email")
private String email;
@Column(nullable = false, name = "age")
private Integer age;
if i for example refresh flyway history and create the same table with another column "country"
CREATE TABLE customer(
id BIGSERIAL PRIMARY KEY,
name TEXT NOT NULL,
email TEXT NOT NULL,
age INT NOT NULL,
country TEXT NOT NULL
)
and when i save it i get the same issue. have a look, it doesn't have the "country" column.
Still the same different table
Here's my docker compose:
services:
db:
container_name: postgres
image: postgres
environment:
POSTGRES_USER: smite
POSTGRES_PASSWORD: 110011
PGDATA: /data/postgres
volumes:
- db:/data/postgres
ports:
- "5332:5432"
networks:
- db
restart: unless-stopped
networks:
db:
driver: bridge
volumes:
db: