I'm uing spring boot with a SQLite DB and spring keeps trying to alter the column AFTER it created the table, however SQLite alter statements only support renaming a table and such. I thought it was obvious enough that the SQLiteDialect would support this by declaring the column as unique during the table's creation but I guess i was wrong. My entity looks like this:
@Entity
@Table(name = "my_entities")
public class MyEntity {
// usual Long id and stuff
@Column(nullable = false, unique = true)
private String word;
// other fields
}
Here's the log output that shows the exception:
Error executing DDL "alter table my_entities add constraint UKegg5ipack6d4292p1uvwopxl6 unique (word)" via JDBC Statement
I considered many options:
- actually modifying SQLiteDialect myself since it's a community dialect anyways, but after looking into it a bit more I realized I would need to do a bit more than just modify a string somewhere
- creating some kind of
import.sql
that has a drop and create statement in it, but it would defy the whole point of having my DB managed for me:
DROP TABLE IF EXISTS my_entities;
CREATE TABLE my_entities(
...
word varchar(255) UNIQUE,
...
);
Eventually, I don't understand why SQLiteDialect can't just create the table from the start with the unique modifier. Does anyone have a solution that makes spring or the dialect do that ?