Skip to content

Closes #262: Copy migrations table to branch #263

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 4 commits into from
May 20, 2025
Merged

Conversation

jeremystretch
Copy link
Contributor

Closes: #262

  • Extends the provision() method on Branch to replicate the current state of the django_migrations table
  • Includes a migration to copy the django_migrations tables to all existing branches

@jeremystretch jeremystretch requested a review from a team May 20, 2025 14:38
@jnovinger jnovinger self-requested a review May 20, 2025 15:24
Copy link

@jnovinger jnovinger left a comment

Choose a reason for hiding this comment

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

Sorry it took a bit, got myself confused between the new main_schema plugin parameter coming in v0.6.0 with the replaced MAIN_SCHEMA constant and where this was landing relative to that. 🤦

I was verifying that all migrations were copied as part of 0004_copy_migrations and realized that, pretty much by definition, it can't copy itself--so all existing branches that this migration updates will be behind by this single migration. I can't decide if I think that's a problem or not.

Just had one other note to leave yourself a reminder, but looks good otherwise.

@@ -540,6 +540,29 @@ def provision(self, user):
f"ALTER TABLE {schema_table} ALTER COLUMN id SET DEFAULT nextval(%s)", [sequence_name]
)

# Copy the migrations table
main_table = f'{MAIN_SCHEMA}.django_migrations'

Choose a reason for hiding this comment

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

Might be worth noting this needs to change in v0.6.0, since the other references to MAIN_SCHEMA are already changed in #254.

Copy link

@jnovinger jnovinger left a comment

Choose a reason for hiding this comment

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

Changing this to a 👍 after thinking through

I was verifying that all migrations were copied as part of 0004_copy_migrations and realized that, pretty much by definition, it can't copy itself--so all existing branches that this migration updates will be behind by this single migration. I can't decide if I think that's a problem or not.

@jeremystretch jeremystretch merged commit 33e4bc5 into main May 20, 2025
7 checks passed
@jeremystretch jeremystretch deleted the 262-copy-migrations branch May 20, 2025 18:40
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.

Copy current migrations table when provisioning a new branch
2 participants