arqam
arqam

Reputation: 3809

SpringBoot : Altering Column length

In my MySQl table, I want to change the length of my column from varchar(2) to varchar(10). I am using docker as my database server.

I tried using columnDefinition but in my table desc I still see the old Type varchar(2). This is the command I added to my Entity Class :

@Column(name = "CHAPTER_CODE", nullable = false, columnDefinition = "varchar(10)")
private String chapterCode;

And then I bootRun the server. Since I am new to SpringBoot, so is there something which I missed.

Upvotes: 2

Views: 4697

Answers (1)

Jonathan JOhx
Jonathan JOhx

Reputation: 5978

You can use length

(Optional) The column length. (Applies only if a string-valued column is used.) By default it is 255

so you should simply add

@Column(name = "CHAPTER_CODE", nullable = false,  length = 10)
private String chapterCode;

Upvotes: 3

Related Questions