Spring boot でデータベースをマイグレーションできない
Spring bootでモデル定義を行いgradle build
コマンドでビルドしようとしましたが下記エラーによりできません。
エラー
> Building 81% > :testERROR: relation "point" does not exist
STATEMENT: alter table point drop constraint FK_i94b2uy0ud0q6jrkb41sqjlrg
ERROR: syntax error at or near "user" at character 13
STATEMENT: alter table user drop constraint FK_1mcjtpxmwom9h9bf2q0k412e0
ERROR: syntax error at or near "group" at character 22
STATEMENT: drop table if exists group cascade
ERROR: syntax error at or near "user" at character 22
STATEMENT: drop table if exists user cascade
ERROR: sequence "hibernate_sequence" does not exist
STATEMENT: drop sequence hibernate_sequence
ERROR: syntax error at or near "group" at character 14
STATEMENT: create table group (id int8 not null, dominate_point int8, player_count int8, primary key (id))
ERROR: syntax error at or near "user" at character 14
STATEMENT: create table user (id int8 not null, consumer_key varchar(255) not null, provider int4 not null, uid varchar(255) not null, profile_id int8, primary key (id))
ERROR: syntax error at or near "user" at character 13
STATEMENT: alter table user add constraint UK_c77nknup654c0jv25o6if51vr unique (consumer_key)
ERROR: syntax error at or near "user" at character 13
STATEMENT: alter table user add constraint FK_1mcjtpxmwom9h9bf2q0k412e0 foreign key (profile_id) references profile
:test
2015-10-28 21:14:50.121 INFO 3555 --- [ Thread-4] o.s.w.c.s.GenericWebApplicationContext : Closing org.springframework.web.context.support.GenericWebApplicationContext@457e0562: startup date [Wed Oct 28 21:14:45 JST 2015]; root of context hierarchy
2015-10-28 21:14:50.130 INFO 3555 --- [ Thread-4] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2015-10-28 21:14:50.130 INFO 3555 --- [ Thread-4] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export
Hibernate: alter table point drop constraint FK_i94b2uy0ud0q6jrkb41sqjlrg
> Building 81% > :test > 1 test completedERROR: syntax error at or near "user" at character 13
STATEMENT: alter table user drop constraint FK_1mcjtpxmwom9h9bf2q0k412e0
Hibernate: alter table user drop constraint FK_1mcjtpxmwom9h9bf2q0k412e0
2015-10-28 21:14:50.134 ERROR 3555 --- [ Thread-4] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table user drop constraint FK_1mcjtpxmwom9h9bf2q0k412e0
2015-10-28 21:14:50.135 ERROR 3555 --- [ Thread-4] org.hibernate.tool.hbm2ddl.SchemaExport : ERROR: syntax error at or near "user"
ポジション: 13
Hibernate: drop table if exists group cascade
> Building 81% > :test > 1 test completedERROR: syntax error at or near "group" at character 22
STATEMENT: drop table if exists group cascade
2015-10-28 21:14:50.136 ERROR 3555 --- [ Thread-4] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: drop table if exists group cascade
2015-10-28 21:14:50.136 ERROR 3555 --- [ Thread-4] org.hibernate.tool.hbm2ddl.SchemaExport : ERROR: syntax error at or near "group"
ポジション: 22
Hibernate: drop table if exists point cascade
Hibernate: drop table if exists profile cascade
> Building 81% > :test > 1 test completedERROR: syntax error at or near "user" at character 22
STATEMENT: drop table if exists user cascade
Hibernate: drop table if exists user cascade
2015-10-28 21:14:50.147 ERROR 3555 --- [ Thread-4] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: drop table if exists user cascade
2015-10-28 21:14:50.147 ERROR 3555 --- [ Thread-4] org.hibernate.tool.hbm2ddl.SchemaExport : ERROR: syntax error at or near "user"
ポジション: 22
Hibernate: drop sequence hibernate_sequence
2015-10-28 21:14:50.155 INFO 3555 --- [ Thread-4] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete
エラーが起きたモデルの定義は下記のとおりです。
userテーブル
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
@Entity
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", nullable = false)
private Long id;
@Column(name = "uid", nullable = false)
private String uid;
@Column(name = "provider", nullable = false)
private Providers provider;
@Column(name = "consumer_key", nullable = false, unique = true)
private String consumerKey;
@OneToOne(cascade = CascadeType.ALL, fetch=FetchType.LAZY)
private Profile profile;
public User() {
super();
}
public String getConsumerKey() {
return consumerKey;
}
public void setConsumerKey(String consumerKey) {
this.consumerKey = consumerKey;
}
public User(Providers provider){
this.provider=provider;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public Providers getProvider() {
return provider;
}
public void setProvider(Providers provider) {
this.provider = provider;
}
}
groupテーブル
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class Group {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", nullable = false)
private Long id;
@Column(name = "player_count")
private Long playerCount;
@Column(name = "dominate_point")
private Long dominatePoint;
public Group() {
super();
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getPlayerCount() {
return playerCount;
}
public void setPlayerCount(Long playerCount) {
this.playerCount = playerCount;
}
public Long getDominatePoint() {
return dominatePoint;
}
public void setDominatePoint(Long dominatePoint) {
this.dominatePoint = dominatePoint;
}
}
pointテーブル
import java.sql.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import org.springframework.data.annotation.CreatedDate;
@Entity
public class Point {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", unique = true)
private Long id;
@Column(name = "latitude")
private float latitude;
@Column(name = "longtitude")
private float longtitude;
@Column(name = "group_id")
private Long groupId;
@CreatedDate
private Date createdAt;
@ManyToOne
private Profile profile;
public Point() {
super();
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public float getLatitude() {
return latitude;
}
public void setLatitude(float latitude) {
this.latitude = latitude;
}
public float getLongtitude() {
return longtitude;
}
public void setLongtitude(float longtitude) {
this.longtitude = longtitude;
}
public Long getGroupId() {
return groupId;
}
public void setGroupId(Long groupId) {
this.groupId = groupId;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Profile getProfile() {
return profile;
}
public void setProfile(Profile profile) {
this.profile = profile;
}
}
エラーを見るとマイグレーションに失敗しているように見えるのですが、何が間違っているのかわかりません。アドバイスをお願いします。
データベースはPostgresqlを使っています。データベースは作成済みです。