Skip to content
This repository was archived by the owner on Oct 26, 2026. It is now read-only.

fix: restore previous api rules when downgrading migration - #3192

Merged
ganigeorgiev merged 1 commit into
pocketbase:masterfrom
impact-merlinzerbe:master
Aug 25, 2023
Merged

ganigeorgiev merged 1 commit into
pocketbase:masterfrom
impact-merlinzerbe:master

Conversation

@impact-merlinzerbe

Copy link
Copy Markdown
Contributor

When changing api rules, the generated down functions clear the api rules instead of setting them to their previous value. So when starting from state A and performing a change to an api rule that is not null/nil/admin-only and subsequently running a migrate down one ends up in state B which is missing the api rule present in state A.

This PR changes the code generation such that the down functions set api rules to their previous value instead of clearing them.

@ganigeorgiev ganigeorgiev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, looks a lot better this way, I don't know why I've implemented it with the messy if/elseif checks.

I left one minor note about the test. Once done, I think it can be merged.

Comment thread plugins/migratecmd/migratecmd_test.go Resolved
@ganigeorgiev

ganigeorgiev commented Aug 25, 2023 •

Copy link
Copy Markdown
Member

Thanks! To avoid the back-and-forth I'll merge it with the latest pushed change and will update only the test to include also the other rule fields for slightly better coverage.

@ganigeorgiev
ganigeorgiev merged commit d423aca into pocketbase:master Aug 25, 2023
ahmed-khaire pushed a commit to ahmed-khaire/postgresbase that referenced this pull request Aug 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants