Skip to content

init_structure.sql out of sync with production

init_structure.sql has a table definition that does not align with what is currently in db/structure.sql and the production table definition.

--- db/init_structure.sql
CREATE TABLE audit_events (
    id bigint NOT NULL,
    author_id integer NOT NULL,
    entity_id integer NOT NULL,
    entity_type character varying NOT NULL,
    details text,
    ip_address inet,
    author_name text,
    target_details text,
    entity_path text,
    created_at timestamp without time zone NOT NULL,
    target_type text,
    target_id bigint,
    CONSTRAINT check_83ff8406e2 CHECK ((char_length(author_name) <= 255)),
    CONSTRAINT check_97a8c868e7 CHECK ((char_length(target_type) <= 255))
)
PARTITION BY RANGE (created_at);
--- db/structure.sql
REATE TABLE audit_events (
    id bigint NOT NULL,
    author_id integer NOT NULL,
    entity_id integer NOT NULL,
    entity_type character varying NOT NULL,
    details text,
    ip_address inet,
    author_name text,
    entity_path text,
    target_details text,
    created_at timestamp without time zone NOT NULL,
    target_type text,
    target_id bigint,
    CONSTRAINT check_492aaa021d CHECK ((char_length(entity_path) <= 5500)),
    CONSTRAINT check_83ff8406e2 CHECK ((char_length(author_name) <= 255)),
    CONSTRAINT check_97a8c868e7 CHECK ((char_length(target_type) <= 255)),
    CONSTRAINT check_d493ec90b5 CHECK ((char_length(target_details) <= 5500))
)
PARTITION BY RANGE (created_at);

And finally, the current production table defintion:

                                    Partitioned table "public.audit_events"
     Column     |            Type             | Collation | Nullable |                 Default                  
----------------+-----------------------------+-----------+----------+------------------------------------------
 id             | bigint                      |           | not null | nextval('audit_events_id_seq'::regclass)
 author_id      | integer                     |           | not null | 
 entity_id      | integer                     |           | not null | 
 entity_type    | character varying(255)      |           | not null | 
 details        | text                        |           |          | 
 ip_address     | inet                        |           |          | 
 author_name    | text                        |           |          | 
 entity_path    | text                        |           |          | 
 target_details | text                        |           |          | 
 created_at     | timestamp without time zone |           | not null | 
 target_type    | text                        |           |          | 
 target_id      | bigint                      |           |          | 
Partition key: RANGE (created_at)
Indexes:
    "audit_events_pkey" PRIMARY KEY, btree (id, created_at)
    "analytics_index_audit_events_part_on_created_at_and_author_id" btree (created_at, author_id)
    "idx_audit_events_part_on_entity_id_desc_author_id_created_at" btree (entity_id, entity_type, id DESC, author_id, created_at)
Check constraints:
    "check_492aaa021d" CHECK (char_length(entity_path) <= 5500)
    "check_83ff8406e2" CHECK (char_length(author_name) <= 255)
    "check_97a8c868e7" CHECK (char_length(target_type) <= 255)
    "check_d493ec90b5" CHECK (char_length(target_details) <= 5500)