mariadb - Custom table creation options in django models -


i have girl model (i mean django =)

class girl(models.model):   id = models.autofield(primary_key=true)    first_name = models.textfield()   last_name = models.textfield()   nickname = models.textfield(blank=true, null=true)   maiden_name = models.textfield(blank=true, null=    = models.textfield(blank=true, null=true)   quotes = models.textfield(blank=true, null=true)   activities = models.textfield(blank=true, null=true)   books = models.textfield(blank=true, null=true)   games = models.textfield(blank=true, null=true)   tv = models.textfield(blank=true, null=true)   interests = models.textfield(blank=true, null=true)   movies = models.textfield(blank=true, null=true)   music = models.textfield(blank=true, null=true)   ...   class meta:     managed = true     db_table = 'girls' 

story: database mariadb+innodb , text fields may contain insanely large unicode poems. i've run problem http://instantbadger.blogspot.ru/2013/01/mysql-row-size-too-large-when-saving.html

problem: in maridb there no way specify default row_format tables via variable (https://jira.mariadb.org/browse/mdev-9646)

question: how can specify option in meta or migration file make django add "row_format=compressed" final sql?

you can add custom sql migration operation inside migration file so:

operations = [     ...     migrations.runsql(""" sql here """) ] 

because want can't done django as-is, can manually add line migration alters table, shown above.

note makes project less flexible: in case decide migrate storage backend doesn't support operation, you'll need rewrite migration. also, when change model changes not reflected in handwritten sql, potentially break things. having said this, it's hard around handwritten query.

alternatively write you're own django package adds functionality model's meta. require writing custom database backend, because far know it's not possible add custom database operations existing database backends.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -