Skip to content

Conversation

bisalgt
Copy link
Contributor

@bisalgt bisalgt commented Sep 21, 2022

Reason for change:

  • Migration Files generated by makemigrations is not considered as migration file if the name of migration file contains . (dot)(excluding the .py extension)

Description:

  • When adding constraints in django model, the migration file was renamed with 00X_constraint_name.py. If the name of constraint has any . then the name of the migration file would be 00X_constraint_.name.py.
  • The generated migration file would be 00X_constraint_.name.py, which the migrate/showmigrations considers as a nonpython file because of .name.py as an extension. So everytime we run makemigrations it would just create a new migrations file. Migrate/ Showmigrations donot find the file as it is not recognized as .py file.
  • After removing the . contained in the file name, migrate /showmigrations is then able to find the new migration files. This makes sure that even though there are any .(dot) in migration file name, it would get replaced and migrate/showmigrations would be able to find the file.

Or maybe we can do self.migration.name.replace(".", "_").replace(" ", "_") for proper naming of migration files at line number 274 of django.db.migrations.writer.py file.

This pull request is also linked to the ticket: https://code.djangoproject.com/ticket/34050#ticket

Regards,
Bishal Gautam

Reason for change: 
- Migration Files generated by makemigrations is not considered as migration files if the name of migration file contains "." (dot)(except the .py extension)
Description: 
- When adding constraints in django model, the migration file was renamed with 00X_constraint_name.py. If the name of constraint has any "." then the name of the migration file would be "00X_constraint_.name.py".
- Because the generated migration file would be "00X_constraint_.name.py", which the makemigrations considers as a nonpython file. So everytime I run makemigrations it would just create a new migrations file. Migrate donot find the file as it is not recognized as ".py" file.
- After removing the "." contained in the file name, migrate and showmigrations is then able to find the new migration files. This makes sure that even though there are any "."(dot) in constraints name or migration file name, it would get replaced in migration file name and migrate/showmigrations would be able to find the file. 
Or maybe even do self.migration.name.replace(".", "_").replace(" ", "_") for proper naming at line number 274 of django.db.migrations.writer.py file.

Regards,
Bishal Gautam
@jacobtylerwalls
Copy link
Member

jacobtylerwalls commented Sep 24, 2022

Hi @bisalgt, could you open a new ticket for this and link your PR? A test and a descriptive commit message title are also required.

@bisalgt
Copy link
Contributor Author

bisalgt commented Sep 24, 2022

Hi @bisalgt, could you open a new ticket for this and link your PR? A test and a descriptive commit message is also required.

Hello @jacobtylerwalls

Thank you for having a look at this pull request. I have created a ticket and with proper description. Please find the ticket associated to this pull request at: https://code.djangoproject.com/ticket/34050#ticket

@felixxm
Copy link
Member

felixxm commented Sep 26, 2022

Closing in favor of #16117.

@felixxm felixxm closed this Sep 26, 2022
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.

3 participants