Tags: xataio/pgroll
Tags
Fix `create_index` operation column ordering (#1009) Change the `create_index` operation to take the columns on which the index should be defined as an list rather than a map. This ensures that the ordering of the columns in in the index is fixed to the same order as they appear in the migration file. **old format** ```yaml # foo operations: - create_index: name: some-index table: tickets columns: column1: {} column2: {} ``` **new format** ```yaml operations: - create_index: name: some-index table: tickets columns: - column: column1 # options - column: column2 # options ``` The changes in this PR are taken from reve-ai#5 🙏⚠️ This is a breaking change to the migration format⚠️ We also modify the `pgroll update` command in this PR so that operations in the old format can be migrated to the new format (although for multi-column indexes the user will still have to ensure that the column order in the updated migration is what they expected). Fixes #1001
Add `--expect-one` flag to `migrate` command (#1005) Add an `--expect-one` flag to the `pgroll migrate` command to allow the command to fail if there is more than one outstanding migration. From the documentation added in this PR: --- By default, `pgroll migrate` will apply all unapplied migrations. However, it may sometimes be desirable to only apply a single migration to ensure that an existing version schema is not removed by a sequence of migrations. In this case, running: ``` $ pgroll migrate examples/ --expect-one ``` will cause the command to fail if more than one unapplied migration is detected.
Stop storing column defaults for `GENERATED` columns (#979) Ensure that generated columns do not have `DEFAULT` values stored in `pgroll`'s internal state representation. Storing default values for generated columns causes breakage when column defaults are applied to versioned views, because the expressions used by generated columns are invalid as column defaults because they typically reference other columns in the same table. Postgres catalogs `pg_attribute` and `pg_attrdef` (where `pgroll` gets column information from when introspecting the database.) **do** store a generated column's expression as a default values for the column, however the higher level system view `information_schema.columns` then filters out default values for generated columns: ```sql SELECT definition FROM pg_views WHERE schemaname = 'information_schema' AND viewname = 'columns'; ``` ```sql # Postgres 17.5 SELECT (current_database())::information_schema.sql_identifier AS table_catalog, ... ( CASE WHEN (a.attgenerated = ''::"char") THEN pg_get_expr(ad.adbin, ad.adrelid) ELSE NULL::text END)::information_schema.character_data AS column_default, ) ... ``` This PR makes `pgroll` behave the same way by not storing `DEFAULT` values for generated columns. Add missing test coverage for generated columns and ensure that tables with generated columns do not break subsequent migrations. Relates to #965 Fixes the regression introduced into `pgroll` `v0.14.0` by #860
Recreate event trigger first in `init.sql` (#948) Move event trigger creation to be the first thing that happens (after `pgroll` schema creation) in `init.sql`. Previous versions of `pgroll` used an event trigger that was incompatible with the latest version, causing errors on the upgrade path to `pgroll 0.14`. By moving event trigger creation to happen first during `init`, we ensure that the old event trigger installed by an older version of `pgroll` can't fire during the `init` of the new version.
Add documentation for `create` subcommand (#820) This PR adds documentation for the new subcommand `create`. 
PreviousNext