我正在使用plaframework 2.2.1,我之前创建了一个MySQL项目,但现在我想将我的项目转移到PostgreSQL,但是在重新创建数据库演变时出现了一些错误。
我的旧的MySQL演变(1.sql)是可以正常工作的:
# --- Created by Ebean DDL
# To stop Ebean DDL generation, remove this comment and start using Evolutions
# --- !Ups
create table product (
id bigint auto_increment not null,
name varchar(255),
price float,
constraint pk_product primary key (id))
;
create table shop (
id bigint auto_increment not null,
name varchar(255),
address_line1 varchar(255),
address_line2 varchar(255),
address_line3 varchar(255),
city varchar(255),
town varchar(255),
phone_number varchar(255),
owner_email varchar(255),
constraint pk_shop primary key (id))
;
create table user (
email varchar(255) not null,
password varchar(255),
first_name varchar(255),
last_name varchar(255),
constraint pk_user primary key (email))
;
create table product_shop (
product_id bigint not null,
shop_id bigint not null,
constraint pk_product_shop primary key (product_id, shop_id))
;
alter table shop add constraint fk_shop_owner_1 foreign key (owner_email) references user (email) on delete restrict on update restrict;
create index ix_shop_owner_1 on shop (owner_email);
alter table product_shop add constraint fk_product_shop_product_01 foreign key (product_id) references product (id) on delete restrict on update restrict;
alter table product_shop add constraint fk_product_shop_shop_02 foreign key (shop_id) references shop (id) on delete restrict on update restrict;
# --- !Downs
SET FOREIGN_KEY_CHECKS=0;
drop table product;
drop table product_shop;
drop table shop;
drop table user;
SET FOREIGN_KEY_CHECKS=1;
然后我已经删除了1.sql,并重新创建了我的进化(1.sql)用于postgresql,如下所示。
# --- !Ups
create table member (
email varchar(255) PRIMARY KEY,
password varchar(255),
first_name varchar(255),
last_name varchar(255)
)
;
create table product (
id bigserial PRIMARY KEY,
name varchar(255),
price real
)
;
create table shop (
id bigserial PRIMARY KEY,
name varchar(255),
address_line1 varchar(255),
address_line2 varchar(255),
address_line3 varchar(255),
city varchar(255),
town varchar(255),
phone_number varchar(255),
email varchar(255) REFERENCES member
)
;
create table product_shop (
product_id bigint REFERENCES product ON DELETE RESTRICT,
shop_id bigint REFERENCES shop ON DELETE CASCADE,
PRIMARY KEY (product_id, shop_id)
)
;
这两个 SQL 有什么区别吗?
我需要添加些什么来使得我的新的 1.sql 函数与旧的 1.sql 在我的 MySQL 进化中相等吗?我的新进化创建了我的数据库,但是当我尝试在我的商店表中插入值时,它显示相同的页面,并且与 MySQL 工作方式不同,即没有加载下一页。在产品表中插入时会显示这个。
[PersistenceException: Error getting sequence nextval]
In C:\Users\Myproject\app\models\Product.java at line 36.
33
34 public static Product create(String name,float price) {
35 Product product = new Product(name, price);
36 product.save();
37 product.saveManyToManyAssociations("shops");
38 return product;
39 }
40 public static void delete(Long id) {
41 find.ref(id).delete();
我也无法在PgAdmin III中找到由2.sql创建的数据库?