NextGen Knowledge Center

Creating the Database

This example channel depends on a database to store resource information. It is setup to support PostgreSQL or SQL Server, though you can modify the code templates to support others. Once you create a schema (e.g. "fhirdb"), here are the other create statements you need:

PostgreSQL:
CREATE SEQUENCE resource_sequence
  INCREMENT 1
  START 1;
CREATE TABLE resource
(
  sequence_id bigint NOT NULL DEFAULT nextval('resource_sequence'::regclass),
  name character varying(255) NOT NULL,
  id character varying(255) NOT NULL,
  version integer NOT NULL,
  data xml,
  mimetype character varying(255),
  last_modified timestamp with time zone DEFAULT now(),
  deleted boolean,
  request_method character varying,
  request_url character varying,
  CONSTRAINT resource_pkey PRIMARY KEY (sequence_id),
  CONSTRAINT resource_unq UNIQUE (name, id, version)
);
SQL Server:
CREATE TABLE resource_sequence
(
  id BIGINT NOT NULL
);
INSERT INTO resource_sequence VALUES (1);
CREATE TABLE resource
(
  sequence_id BIGINT NOT NULL,
  name NVARCHAR(255) NOT NULL,
  id NVARCHAR(255) NOT NULL,
  version INTEGER NOT NULL,
  data XML,
  mimetype NVARCHAR(255),
  last_modified DATETIMEOFFSET DEFAULT CURRENT_TIMESTAMP,
  deleted BIT,
  request_method NVARCHAR(MAX),
  request_url NVARCHAR(MAX),
  CONSTRAINT resource_pkey PRIMARY KEY (sequence_id),
  CONSTRAINT resource_unq UNIQUE (name, id, version)
);