tortoise / tortoise/tortoise-orm
add an option to create raw SQL statement in tortoise makemigrations.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
Is your feature request related to a problem? Please describe.
I wish to add a field like data = fields.JSONField(default=dict) and tweak SQL statement to make default not NULL. (with default '{}' in SQL statement)
Describe the solution you'd like
While this is possible to do manually now, I wish some command line options that populates ops.RunSQL instead of ops.AddField, so I don't need to run tortoise sqlmigrate and copy paste to migration file.
maybe tortoise makemigrations --raw or tortoise makemigrations --sql ?
Describe alternatives you've considered
Tweak the migration file manually, but would be quicker to do if I can have SQL statement generated with migration file.
Additional context
https://github.com/tortoise/tortoise-orm/discussions/2233
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the tortoise makemigrations command and how it differs from tortoise sqlmigrate. Compare the generated ops.AddField migration with the requested ops.RunSQL output, using the proposed --raw or --sql behavior as the scope. Done means a documented command option generates a migration containing the appropriate raw SQL statement.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100