Environment
- PostgreSQL 9.5
- PostgREST 5.2
- Operating system: win7 x64
Description of issue ,step
- There is a stored procedure that creates tables based on SQL statements and passes them by array。
for example
- sql---companys
CREATE TABLE public.companys
(
id uuid NOT NULL,
status boolean,
"companyName" character varying(128) COLLATE pg_catalog."default",
"legPerson" character varying(128) COLLATE pg_catalog."default",
email character varying(100) COLLATE pg_catalog."default",
"projectName" character varying(128) COLLATE pg_catalog."default",
"powerName" character varying(128) COLLATE pg_catalog."default",
"roleName" character varying(128) COLLATE pg_catalog."default",
"deptName" character varying(128) COLLATE pg_catalog."default",
"userRole" character varying(128) COLLATE pg_catalog."default",
"userDept" character varying(128) COLLATE pg_catalog."default",
"rolePower" character varying(128) COLLATE pg_catalog."default",
phone character varying(64) COLLATE pg_catalog."default",
CONSTRAINT companys_pkey PRIMARY KEY (id)
)
2.sql--users (There is a foreign key binding relationship)
CREATE TABLE public.users
(
id uuid NOT NULL,
"userName" character varying(40) COLLATE pg_catalog."default",
"userPassword" character varying(200) COLLATE pg_catalog."default",
phone character varying(40) COLLATE pg_catalog."default",
email character varying(100) COLLATE pg_catalog."default",
"companyName" character varying(80) COLLATE pg_catalog."default",
"companyId" uuid,
note text COLLATE pg_catalog."default",
CONSTRAINT users_pkey PRIMARY KEY (id),
CONSTRAINT "users_companyId_fkey" FOREIGN KEY ("companyId")
REFERENCES public.companys (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
post ip:port/create_table
{
companys,users
}
qurey data by get /users?select=,companys()
{
"message": "Could not find foreign keys between these entities, No relation found between users and users"
}
4.If the service is restarted, everything will be fine,why? is bug or not support?tell me
thanks。
Most helpful comment
PostgREST caches the database schema on startup, and doesn't refresh the cache. So, PostgREST doesn't know about the new tables you created with that sproc.
See here in the docs for more details