
CREATE TABLE impounds (
    vin character varying(17) NOT NULL,
    impounddate date NOT NULL,
    eventtypeid integer NOT NULL,
    ori character varying(9),
    platenumber character varying(8),
    platestate character varying(2),
    plateyear integer,
    platetype character varying(2),
    vehicleyear integer,
    vehiclemake text,
    vehiclemodel text,
    vehiclestyle text,
    vehiclecolor text,
    townotes text,
    damagenotes text,
    platenotes text,
    custodynotes text,
    sourcenotes text,
    referencenumber1 text,
    referencenumber2 text,
    referencenumber3 text,
    contactname text,
    contactphone text
);



ALTER TABLE ONLY impounds
    ADD CONSTRAINT impounds_pk PRIMARY KEY (vin, impounddate, eventtypeid);

CREATE TABLE impounds_s1 () INHERITS (impounds);
CREATE TABLE impounds_s2 () INHERITS (impounds);
CREATE TABLE impounds_s3 () INHERITS (impounds);
CREATE TABLE impounds_s4 () INHERITS (impounds);

ALTER TABLE impounds_s1 ADD CONSTRAINT impounds_s1_pk PRIMARY KEY (vin, impounddate);
ALTER TABLE impounds_s2 ADD CONSTRAINT impounds_s2_pk PRIMARY KEY (vin, impounddate);
ALTER TABLE impounds_s3 ADD CONSTRAINT impounds_s3_pk PRIMARY KEY (vin, impounddate);
ALTER TABLE impounds_s4 ADD CONSTRAINT impounds_s4_pk PRIMARY KEY (vin, impounddate);



CREATE TABLE liens (
    agentid integer NOT NULL,
    vin character varying(17) NOT NULL,
    liendate date,
    accountnumber character varying(50),
    customername character varying(50),
    state character varying(2),
    vehiclemake character varying(20),
    vehiclemodel character varying(20),
    vehicleyear integer
);

ALTER TABLE ONLY liens
    ADD CONSTRAINT liens_pk PRIMARY KEY (vin, agentid);

CREATE TABLE liens_s1 () INHERITS (liens);
CREATE TABLE liens_s2 () INHERITS (liens);
CREATE TABLE liens_s3 () INHERITS (liens);
CREATE TABLE liens_s4 () INHERITS (liens);
CREATE TABLE liens_s5 () INHERITS (liens);
CREATE TABLE liens_s6 () INHERITS (liens);
CREATE TABLE liens_s7 () INHERITS (liens);

ALTER TABLE liens_s1 ADD CONSTRAINT lines_s1_pk PRIMARY KEY (vin);
ALTER TABLE liens_s2 ADD CONSTRAINT lines_s2_pk PRIMARY KEY (vin);
ALTER TABLE liens_s3 ADD CONSTRAINT lines_s3_pk PRIMARY KEY (vin);
ALTER TABLE liens_s4 ADD CONSTRAINT lines_s4_pk PRIMARY KEY (vin);
ALTER TABLE liens_s5 ADD CONSTRAINT lines_s5_pk PRIMARY KEY (vin);
ALTER TABLE liens_s6 ADD CONSTRAINT lines_s6_pk PRIMARY KEY (vin);
ALTER TABLE liens_s7 ADD CONSTRAINT lines_s7_pk PRIMARY KEY (vin);

