Opened 8 months ago

Closed 8 months ago

Last modified 8 months ago

#23263 closed Cleanup/optimization (fixed)

Document sqlmigrate in migrations topic guide

Reported by: wizpig64 Owned by: nobody
Component: Documentation Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

makemigrations has --dry-run and --verbosity 3, but that's for seeing what migrations will be generated, not the SQL itself.

According to Andrew in this south ticket, it may be a harder question than it appears at first glance, because the actual SQL isn't known until it can ask the database a few things, and showing SQL for multiple changes would be a big mess too: http://south.aeracode.org/ticket/480

Being able to inspect the SQL to be run is a crucial feature for a migration tool. Fooling around with 1.7rc2's migrations so far, I've run a few initial migrations on a test database that have changed columns in ways that were never told to me. Undoing those migrations *dropped the tables*, and I didn't know about it until my applications started complaining. I admit, these unexpected changes are mostly likely due to how my models weren't 100% accurate to the tables created outside of django by legacy software. I don't blame django for them.

For now though, I'm uncomfortable running any migrations without knowing exactly what they're going to do. This feature probably isn't needed by people running apps that are and always have been 100% django. But as someone in the trenches dealing with messy data structures from decades ago, I need a tool that will help me manage my data structures, not one that will obscure them from me. So for now, I'll stick to diffing between sqlall outputs, as tedious as it is. Thanks.

Change History (6)

comment:1 Changed 8 months ago by timgraham

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Isn't this what sqlmigrate does?

comment:2 Changed 8 months ago by knyghty

  • Version changed from 1.7-rc-2 to master

comment:3 Changed 8 months ago by wizpig64

@timgraham

It seems you're right. The migrations documentation page doesn't mention the sqlmigrate: https://docs.djangoproject.com/en/1.7/topics/migrations/ - Could it be updated then?

comment:4 Changed 8 months ago by bmispelon

  • Component changed from Migrations to Documentation
  • Easy pickings set
  • Summary changed from add migrate --dry-run and --verbose to show database changes in SQL to Document sqlmigrate in migrations topic guide
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from New feature to Cleanup/optimization

Adding a link and/or a brief explanation of what sqlmigrate does on the topics page makes sense.

I'm accepting this ticket on this basis.

Thanks.

comment:5 Changed 8 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 7ed3d0bb61f46f56b8a001b7b2d983eaf9a65466:

Fixed #23263 -- Added sqlmigrate to migration topic guide.

comment:6 Changed 8 months ago by Tim Graham <timograham@…>

In ad2faaa4918ff1cfce2671a91d0e016515319481:

[1.7.x] Fixed #23263 -- Added sqlmigrate to migration topic guide.

Backport of 7ed3d0bb61 from master

Note: See TracTickets for help on using tickets.
Back to Top