Skip to content

[FEATURE] Change [run_id] to auto-incrementing IDENTITY(1, 1) column #266

Description

@Eric-Liu-SANDAG

Is your feature request related to a problem? Please describe

In the current code, [run_id] is a simple INTEGER column, and parsers.py takes care of ensuring there is no [run_id] clash by getting the current maximum value and adding one. This is dangerous, as we sometimes delete [run_id]s, which means we could get clashes over time. This actually happened in a non-consequential way with reporting.py, which has it's current [run_id] to check as 245, but the current max [run_id] actually in [metadata].[run] is 222

Describe the solution you'd like

Changing the column to IDENTITY(1, 1) would solve this issue. An IDENTITY column guarantees that once a value is inserted into the table, it will never repeat (unless someone or something manually adjusts the index, but there's never any reason to and no one ever should).

In terms of actual implementation, this would slightly change the insertion script into [metadata].[run] and create_objects.sql, but otherwise no other code changes would be necessary. If this change is actually made, it would probably require a one time adjustment of the index to some arbitrary value like 250 or something to be safe

Describe alternatives you've considered

N/A

Additional context

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions