postgresql 中的 Flyway 迁移?
Flyway migration in postgresql?
我正在尝试使用这样的请求向 Postgresql 添加一个条目
insert into customer (id, email, name, number_telephone) VALUES (public.hibernate_sequence_customer.nextval, 'abc@jar.ru' , 'Henry', '89132547898');
,但 flyway 抛出错误
Error: table "hibernate_sequence_customer" is missing in the FROM clause
在项目结构中
enter image description here
序列的下一个值是 accessed,通过 nextval('public.hibernate_sequence_customer')
,而不是点符号。
insert into customer (
id,
email,
name,
number_telephone)
VALUES (
nextval('public.hibernate_sequence_customer'),
'abc@jar.ru' ,
'Henry',
'89132547898');
但是如果你将id
列定义为serial
,你根本不需要调用序列。
create table customer (
id serial primary key,
email text,
name text,
number_telephone text);
只需在您的 insert
中跳过它:
insert into customer (
email,
name,
number_telephone)
VALUES (
'abc@jar.ru' ,
'Henry',
'89132547898');
如果您稍后需要引用负责 id
列的序列 - 例如获取其当前值 - 您可以使用 currval(pg_get_serial_sequence('customer','id'))
.
我正在尝试使用这样的请求向 Postgresql 添加一个条目
insert into customer (id, email, name, number_telephone) VALUES (public.hibernate_sequence_customer.nextval, 'abc@jar.ru' , 'Henry', '89132547898');
,但 flyway 抛出错误
Error: table "hibernate_sequence_customer" is missing in the FROM clause
在项目结构中 enter image description here
序列的下一个值是 accessed,通过 nextval('public.hibernate_sequence_customer')
,而不是点符号。
insert into customer (
id,
email,
name,
number_telephone)
VALUES (
nextval('public.hibernate_sequence_customer'),
'abc@jar.ru' ,
'Henry',
'89132547898');
但是如果你将id
列定义为serial
,你根本不需要调用序列。
create table customer (
id serial primary key,
email text,
name text,
number_telephone text);
只需在您的 insert
中跳过它:
insert into customer (
email,
name,
number_telephone)
VALUES (
'abc@jar.ru' ,
'Henry',
'89132547898');
如果您稍后需要引用负责 id
列的序列 - 例如获取其当前值 - 您可以使用 currval(pg_get_serial_sequence('customer','id'))
.