This is a general question. I'll give a sample of what I am concerned about, but the general idea I am after is: can I bypass migrations to manage the schema for the models? Now, I know there are lots of good reasons people like migrations, but I am proficient with DDL SQL and looking after schema changes and am finding that, for my use cases, I spend way more time working around migrations than I do benefiting from them. I don't use fixtures for example and I don't need very dynamic migration capability a la Chef/Puppet, at least not until I am in production.
In fact, I find the lack of transparency around migration DDL quite scary.
This is just a sample issue I am dealing with:
class Profile(models.Model):
rdbname = RDBNAME
name = models.CharField(max_length=80, blank=True)
creation = models.DateTimeField(auto_now=True)
rolecount = models.IntegerField(default=0)
usercount = models.IntegerField(default=0)
def __unicode__(self):
return self.name
class Meta:
ordering = ["-rolecount", "name"]
I have just added this index, it shows up in migrations, but it doesn't get created
unique_together = ("rdbname", "name")
This is the output:
Running migrations:
No migrations to apply.
But this is NOT a request to help me troubleshoot my migration. I can probably drop the affected tables get migrations to recreate them. Or add the index by hand. I just generally don't want to use manage.py migrate and I wonder if there are ways to benefit from Models but look after your db the old fashioned, manual way.
One possible approach would be to use makemigrations in a "from-scratch/dry-run/sql output" mode to create a sql script. With all drop/create tables and indices, as if the database was empty. If you compare that to your previous from-scratch, you would see whatever was changed and you could create a script to say just add a column. Or my index in my case.
And you would execute that in your favorite sql utility, psql (Postgres) in my case.
Can I not get a long set of explanations why migrations are the cat's pajamas? I am aware of those already. But I would be happy to hear from people who have tried that there is no way out, that's a useful data point for me. I'll just have to bite the bullet as well.
Just wondering if anyone else has managed to work around them somewhat.