harvard-lil / h2o

H2O is a web app for creating and reading open educational resources, primarily in the legal field
https://opencasebook.org
GNU Affero General Public License v3.0
37 stars 30 forks source link

Add indexes for fields in LegalDocument; fixes #1951 #1952

Closed lizadaly closed 1 year ago

lizadaly commented 1 year ago

Results in the following schema:

Before

postgres=# \d main_legaldocument;
                                           Table "public.main_legaldocument"
      Column      |            Type            | Collation | Nullable |                    Default                     
------------------+----------------------------+-----------+----------+------------------------------------------------
 id               | integer                    |           | not null | nextval('main_legaldocument_id_seq'::regclass)
 created_at       | timestamp with time zone   |           |          | 
 updated_at       | timestamp with time zone   |           |          | 
 name             | character varying(10000)   |           |          | 
 short_name       | character varying(150)     |           |          | 
 jurisdiction     | character varying(20)      |           |          | 
 doc_class        | character varying(100)     |           |          | 
 citations        | character varying(500)[]   |           | not null | 
 effective_date   | timestamp with time zone   |           |          | 
 publication_date | timestamp with time zone   |           |          | 
 updated_date     | timestamp with time zone   |           |          | 
 source_ref       | character varying(10000)   |           | not null | 
 content          | character varying(5242880) |           | not null | 
 metadata         | jsonb                      |           |          | 
 source_id        | integer                    |           | not null | 
Indexes:
    "main_legaldocument_pkey" PRIMARY KEY, btree (id)
    "main_legald_citatio_34c035_gin" gin (citations)
    "main_legaldocument_source_id_daa1c7e8" btree (source_id)
Foreign-key constraints:
    "main_legaldocument_source_id_daa1c7e8_fk_main_lega" FOREIGN KEY (source_id) REFERENCES main_legaldocumentsource(id) DEFERRABLE INITIALLY DEFERRED

After

postgres=# \d main_legaldocument;
                                           Table "public.main_legaldocument"
      Column      |            Type            | Collation | Nullable |                    Default                     
------------------+----------------------------+-----------+----------+------------------------------------------------
 id               | integer                    |           | not null | nextval('main_legaldocument_id_seq'::regclass)
 created_at       | timestamp with time zone   |           |          | 
 updated_at       | timestamp with time zone   |           |          | 
 name             | character varying(10000)   |           |          | 
 short_name       | character varying(150)     |           |          | 
 jurisdiction     | character varying(20)      |           |          | 
 doc_class        | character varying(100)     |           |          | 
 citations        | character varying(500)[]   |           | not null | 
 effective_date   | timestamp with time zone   |           |          | 
 publication_date | timestamp with time zone   |           |          | 
 updated_date     | timestamp with time zone   |           |          | 
 source_ref       | character varying(10000)   |           | not null | 
 content          | character varying(5242880) |           | not null | 
 metadata         | jsonb                      |           |          | 
 source_id        | integer                    |           | not null | 
Indexes:
    "main_legaldocument_pkey" PRIMARY KEY, btree (id)
    "main_legald_citatio_34c035_gin" gin (citations)
    "main_legaldocument_doc_class_0e4ac3d9" btree (doc_class)
    "main_legaldocument_doc_class_0e4ac3d9_like" btree (doc_class varchar_pattern_ops)
    "main_legaldocument_effective_date_afe55c31" btree (effective_date)
    "main_legaldocument_publication_date_5d36cbeb" btree (publication_date)
    "main_legaldocument_source_id_daa1c7e8" btree (source_id)
    "main_legaldocument_source_ref_c1b07d13" btree (source_ref)
    "main_legaldocument_source_ref_c1b07d13_like" btree (source_ref varchar_pattern_ops)
Foreign-key constraints:
    "main_legaldocument_source_id_daa1c7e8_fk_main_lega" FOREIGN KEY (source_id) REFERENCES main_legaldocumentsource(id) DEFERRABLE INITIALLY DEF
ERRED
lizadaly commented 1 year ago

Oops, also want to add updated_date here.