Skip to content

Conversation

@davenquinn
Copy link
Member

@davenquinn davenquinn commented Dec 17, 2025

Modernize stratigraphy rebuild scripts

Scripts

  • autocomplete
  • lookup_strat_names
  • lookup_unit_attrs_api
  • lookup_unit_intervals
  • lookup_units
  • pbdb_matches
  • stats
  • strat_name_footprints
  • unit_boundaries

Tasks for each script

  • Convert the database access from MariaDB to PostgreSQL
  • Clean up control flow and use more modern parameter binding
  • Other fixes for usability

Some of these scripts are outdated, so they may not work without some modification. But we should start with direct SQL translation where possible.

Many run lots of SQL and so might benefit from being run/tested against a local database, or on the cluster.

Our new macrostrat.database library should make the SQL a lot terser and easier to read.

Overall process

  • Convert all scripts to PostgreSQL
  • Check for correct output in macrostrat schema and API results (number of rows, output structure)
  • Move the ~finalized scripts out of the v1 schema

@davenquinn davenquinn marked this pull request as draft December 17, 2025 10:39
…modernize-rebuild-scripts

* origin/modernize-rebuild-scripts:
  Format code and sort imports
@davenquinn
Copy link
Member Author

In working on the first few scripts, autocomplete and lookup_strat_names, it seems like one of the only major SQL changes needed to migrate from MariaDB to PostgreSQL syntax is a change from the
UPDATE <table> LEFT JOIN <other table> SET ... WHERE ... syntax
to the UPDATE <table> SET ... FROM <other table> WHERE ... <join_condition> syntax. This may cause weirdness about the join condition (i.e., whether rows with NULLS are included) – we'll have to monitor this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants