Skip to content

Add new group Guides and add a guide for writing up and down expresions #775

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 4, 2025

Conversation

kvch
Copy link
Contributor

@kvch kvch commented Apr 2, 2025

This PR adds a new section to the sidebar dedicated to guides. In this part of the documentation we could add guides for using pgroll with ORMs, baselining, etc.

The first guide I am adding is about writing up and down expressions in pgroll operations.

@github-actions github-actions bot temporarily deployed to Docs Preview April 2, 2025 13:05 Inactive
@kvch kvch force-pushed the docs-add-up-down-guide branch from 353ce14 to ab2b3d4 Compare April 2, 2025 13:06
@github-actions github-actions bot temporarily deployed to Docs Preview April 2, 2025 13:07 Inactive
@kvch kvch requested review from OysterKing and exekias April 2, 2025 13:14
description: Guide to writing up and down migrations
---

In this guide you will learn how to write `up` and `down` migrations in your pgroll operations. First, we are looking at how `up` and `down` migrations work. Then we are going through a few examples.
Copy link

@OysterKing OysterKing Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion:

In this guide, you will learn...

I suggest saying "we will learn", that's what I would expect in most guides.

Then we are going through a few examples.

Change to "then we'll look at a few examples".


## What is an `up` and `down` migration of a pgroll operation?

Most pgroll migrations include `up` and `down` migrations. When `pgroll` is migrating tables, it creates `up` and `down` triggers. The `up` triggers backfill the records in the table. The `down` triggers are running during rollback.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When pgroll is migrating tables...

Change to "When pgroll migrates tables..."

The down triggers are running during rollback.

Change to "The down triggers run during rollback."

Co-authored-by: Richard Gill <richardgill@users.noreply.github.com>
@github-actions github-actions bot temporarily deployed to Docs Preview April 2, 2025 13:53 Inactive
@github-actions github-actions bot temporarily deployed to Docs Preview April 2, 2025 14:58 Inactive

## What is an `up` and `down` migration of a `pgroll` operation?

Most `pgroll` migrations include `up` and `down` migrations. When `pgroll` migrates tables, it creates `up` and `down` triggers. The `up` triggers backfill the records in the table. The `down` triggers run during rollback.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both up & down triggers are run when updating the table, depending on the version the table is being updated with:

  • up is always run to backfill new columns (if any), during the start process
  • up is also run for any insert/update of rows in the old version of the schema
  • down is run for any insert/update of rows in the new version of the schema.

I believe it would be good to add some more explanations here

@kvch kvch requested a review from exekias April 2, 2025 15:32
@github-actions github-actions bot temporarily deployed to Docs Preview April 2, 2025 15:32 Inactive
@github-actions github-actions bot temporarily deployed to Docs Preview April 3, 2025 12:49 Inactive
@kvch kvch enabled auto-merge (squash) April 4, 2025 08:15
@kvch kvch merged commit 48f1d61 into xataio:main Apr 4, 2025
30 checks passed
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.

4 participants