Skip to content

Frozen CreateTable operation so making changes to schema is actually possible#26

Merged
maroux merged 5 commits intomasterfrom
frozen_create_table_operation
Nov 17, 2020
Merged

Frozen CreateTable operation so making changes to schema is actually possible#26
maroux merged 5 commits intomasterfrom
frozen_create_table_operation

Conversation

@maroux
Copy link
Owner

@maroux maroux commented Nov 16, 2020

Migrations should use schema definition frozen in time at the time of creation so that updating models code doesn't automatically affect a historical migration.

  • Also check black formatting in tests

@maroux maroux requested a review from techgerm November 16, 2020 21:51
@techgerm
Copy link
Collaborator

Can you elaborate a little more on "frozen CreateTable" and "so making changes to schema is actually possible"? Do you mean as opposed to making migrations? I'm trying to follow your reasoning while reviewing your code.

@maroux
Copy link
Owner Author

maroux commented Nov 17, 2020

Can you elaborate a little more on "frozen CreateTable" and "so making changes to schema is actually possible"? Do you mean as opposed to making migrations? I'm trying to follow your reasoning while reviewing your code.

If you create a migration with operation CreateTable(model) and then remove a field, that migration will not create the field in a new database. Instead, it should create the model frozen in time, such that when its applied again - the field is created and then later dropped using a different migration. Without doing it this way, running migrations in test code isn't possible because the field you want to drop would not exist.

@maroux
Copy link
Owner Author

maroux commented Nov 17, 2020

This is similar to how alembic migrations work - the list of fields, types, indexes etc are frozen when migration is created.

@techgerm
Copy link
Collaborator

Ah gotcha, makes sense ... thanks for elaborating 👌

@maroux maroux merged commit 4aee01c into master Nov 17, 2020
@maroux maroux deleted the frozen_create_table_operation branch November 17, 2020 20:48
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.

2 participants