{"id":324,"date":"2017-01-23T03:15:46","date_gmt":"2017-01-22T19:15:46","guid":{"rendered":"http:\/\/vinta.ws\/code\/?p=324"},"modified":"2026-02-18T01:20:36","modified_gmt":"2026-02-17T17:20:36","slug":"create-a-custom-migration-in-django","status":"publish","type":"post","link":"https:\/\/vinta.ws\/code\/create-a-custom-migration-in-django.html","title":{"rendered":"Create a custom migration in Django"},"content":{"rendered":"<pre class=\"line-numbers\"><code class=\"language-bash\"># create an empty migration file\n$ .\/manage.py makemigrations --empty --name convert_to_utf8mb4 your_app<\/code><\/pre>\n<p>in your_app\/migrations\/0002_convert_to_utf8mb4.py<\/p>\n<pre class=\"line-numbers\"><code class=\"language-py\">from __future__ import unicode_literals\n\nfrom django.db import migrations\n\nclass Migration(migrations.Migration):\n\n    dependencies = [\n        ('your_app', '0001_initial'),\n    ]\n\n    operations = [\n        migrations.RunSQL(\n            'ALTER TABLE app_repostarring CHANGE repo_description repo_description VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'\n        ),\n    ]<\/code><\/pre>\n<p>ref:<br \/>\n<a href=\"https:\/\/docs.djangoproject.com\/en\/dev\/ref\/migration-operations\/#runsql\">https:\/\/docs.djangoproject.com\/en\/dev\/ref\/migration-operations\/#runsql<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ALTER TABLE app_repostarring CHANGE repo_description repo_description VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;<\/p>\n","protected":false},"author":1,"featured_media":325,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,4],"tags":[59,13,95,23,2],"class_list":["post-324","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-about-database","category-about-python","tag-database-migrations","tag-django","tag-django-models","tag-mysql","tag-python"],"_links":{"self":[{"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/posts\/324","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/comments?post=324"}],"version-history":[{"count":0,"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/posts\/324\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/media\/325"}],"wp:attachment":[{"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/media?parent=324"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/categories?post=324"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vinta.ws\/code\/wp-json\/wp\/v2\/tags?post=324"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}