PostgreSQL一对一关系不存在

时间:2019-02-04 13:35:25

标签: postgresql

CREATE TABLE IF NOT EXISTS client (
  id SERIAL NOT NULL PRIMARY KEY,
  company_name text NOT NULL,
  firm_reg_no numeric NULL,
  address text NULL,
  client_name text NULL,
  phone_1 numeric NULL,
  phone_2 numeric NULL,
  email text NULL,
  explanation text NULL,
  rating decimal NULL,
  status active_status NOT NULL DEFAULT 'active',
  create_time TIMESTAMP without TIME ZONE DEFAULT now() NOT NULL,
  update_time TIMESTAMP without TIME ZONE DEFAULT now() NOT NULL,
  client_contract_id numeric NOT NULL,
  work_detail_id numeric NULL,
  CONSTRAINT fk_client_client_contract FOREIGN KEY (client_contract_id) REFERENCES client_contract (id)
  ON DELETE NO ACTION ON UPDATE NO ACTION
);

CREATE TABLE IF NOT EXISTS client_contract (
  id SERIAL NOT NULL PRIMARY KEY,
  contract_no integer NULL,
  start_date DATE NULL,
  end_date DATE NULL,
  is_temporary BOOLEAN NOT NULL default false,
  is_archived BOOLEAN NOT NULL default false,
  create_time TIMESTAMP without TIME ZONE DEFAULT now() NOT NULL,
  update_time TIMESTAMP without TIME ZONE DEFAULT now() NOT NULL,
  monthly_pay decimal NULL
  );

这给我一个错误,提示“关系“ client_contract”不存在。

每个客户都有一份合同,管理员可以更改合同条款。

我该如何解决?

0 个答案:

没有答案