我正在使用plaframework 2.2.1,我做了一個項目MySQL,但現在我想將項目轉移到PostgreSQL,但有一些錯誤重新創建數據庫的演變。轉換播放!從MySQL到PostgreSQL的框架演化
我的老演進(1.SQL),用於其工作的罰款是mysql:
# --- 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)下面
# --- !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)
)
;
給出的PostgreSQL
這兩個sql有什麼區別嗎?
我需要添加一些東西,以使我的新的1.sql功能與我的mysql進化中的舊版1.sql相同嗎?我的新進化創建了我的數據庫,但是當我試圖在我的商店表中插入值時,它顯示相同的頁面,並且它與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();
我也無法找到由2.SQL中的pgAdmin III創建我的數據庫?
當你說「有些錯誤」時,你說的是什麼意思?請準確填寫錯誤消息文本。 –
我的意思是我的進化創建了我的數據庫,我可以通過瀏覽器中的項目在我的成員表中插入值,但是當我輸入url來顯示向我顯示在產品詳細信息中插入數據的表單時,它顯示錯誤PersistanceException reloation product does不存在 – akku
請*複製錯誤*並將其粘貼到您的問題中。使用「編輯」按鈕。 –