Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 36 additions & 3 deletions postgres/CreateTables.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def create_dockets_table(conn: psycopg.Connection):

def create_documents_table(conn: psycopg.Connection):
query = """
CREATE TABLE documents (
CREATE TABLE documentsWithFRDoc (
document_id VARCHAR(50) NOT NULL PRIMARY KEY,
document_api_link VARCHAR(2000) NOT NULL UNIQUE,
address1 VARCHAR(200),
Expand Down Expand Up @@ -126,10 +126,42 @@ def create_documents_table(conn: psycopg.Connection):
document_title VARCHAR(500),
topics VARCHAR(250)[],
is_withdrawn BOOLEAN DEFAULT FALSE,
postal_code VARCHAR(10)
postal_code VARCHAR(10),
frdocnum VARCHAR(50),
attachments_self_link VARCHAR(2000),
attachments_related_link VARCHAR(2000),
file_formats JSONB,
display_properties JSONB
);
"""
_create_table(conn, query, "documents")
_create_table(conn, query, "documentsWithFRDoc")

def create_federal_register_docs_table(conn: psycopg.Connection):
query = """
CREATE TABLE federal_register_documents (
document_number VARCHAR(50) NOT NULL PRIMARY KEY,
document_id VARCHAR(50),
document_title TEXT,
document_type VARCHAR(50),
abstract TEXT,
publication_date DATE,
effective_on DATE,
docket_ids TEXT[],
agency_id VARCHAR(20),
agency_names TEXT[],
topics TEXT[],
significant BOOLEAN,
regulation_id_numbers TEXT[],
html_url VARCHAR(2000),
pdf_url VARCHAR(2000),
json_url VARCHAR(2000),
start_page INTEGER,
title VARCHAR(50),
cfrpart VARCHAR(50),
end_page INTEGER
);
"""
_create_table(conn, query, "federal_register_documents")


def main():
Expand All @@ -155,6 +187,7 @@ def main():
create_dockets_table(conn)
create_documents_table(conn)
create_comments_table(conn)
create_federal_register_docs_table(conn)

conn.close()

Expand Down
6 changes: 5 additions & 1 deletion postgres/DropTables.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ def drop_dockets_table(conn: psycopg.Connection):


def drop_documents_table(conn: psycopg.Connection):
_drop_table(conn, "documents")
_drop_table(conn, "documentsWithFRDoc")

def drop_fed_reg_docs_table(conn: psycopg.Connection):
_drop_table(conn, "federal_register_documents")


def main():
Expand Down Expand Up @@ -69,6 +72,7 @@ def main():
drop_comments_table(conn)
drop_dockets_table(conn)
drop_documents_table(conn)
drop_fed_reg_docs_table(conn)

conn.close()

Expand Down