Skip to content

Instantly share code, notes, and snippets.

@indy-singh
Created May 3, 2020 11:04
Show Gist options
  • Save indy-singh/6ccd86ff859e7cdad2ec1bf73a61445c to your computer and use it in GitHub Desktop.
Save indy-singh/6ccd86ff859e7cdad2ec1bf73a61445c to your computer and use it in GitHub Desktop.
proposal.proposal.sql
-- Table: proposal.proposal
-- DROP TABLE proposal.proposal;
CREATE TABLE proposal.proposal
(
id bigserial NOT NULL,
reference uuid NOT NULL,
system_id integer NOT NULL,
legacy_id integer NOT NULL,
organisation_id integer,
legacy_organisation_id integer NOT NULL,
has_been_anonymised boolean NOT NULL,
external_source character varying,
CONSTRAINT pk_proposal PRIMARY KEY (id),
CONSTRAINT proposal_reference_key UNIQUE (reference),
CONSTRAINT proposal_system_id_legacy_id_key UNIQUE (system_id, legacy_id)
);
-- Index: proposal.proposal_has_been_anonymised_system_id_legacy_organisation__idx
-- DROP INDEX proposal.proposal_has_been_anonymised_system_id_legacy_organisation__idx;
CREATE INDEX proposal_has_been_anonymised_system_id_legacy_organisation__idx
ON proposal.proposal
USING btree
(has_been_anonymised, system_id, legacy_organisation_id);
-- Index: proposal.proposal_has_been_anonymised_system_id_legacy_organisation_idx1
-- DROP INDEX proposal.proposal_has_been_anonymised_system_id_legacy_organisation_idx1;
CREATE INDEX proposal_has_been_anonymised_system_id_legacy_organisation_idx1
ON proposal.proposal
USING btree
(has_been_anonymised, system_id, legacy_organisation_id, reference);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment